First, get Lao Wang’s current ranking: ZRANK ranks 老王, assuming Lao Wang’s ranking is Nth.
(The top 5 I am talking about here refer to those with a higher score than Lao Wang, and the bottom 5 are those with a smaller score than Lao Wang)
Then Lao Wang’s top 5 are: ZRANGE ranks N+1 N+6,
Lao Wang’s last 5 are: ZRANGE ranks N-6 N-1.
To put it all together, plus Lao Wang himself, it is: ZRANGE ranks N-6 N+6.
Note: You must remember to first determine whether N-6 and N-1 are less than 0.
First, get Lao Wang’s current ranking:
ZRANK ranks 老王
, assuming Lao Wang’s ranking is Nth.(The top 5 I am talking about here refer to those with a higher score than Lao Wang, and the bottom 5 are those with a smaller score than Lao Wang)
Then Lao Wang’s top 5 are:
ZRANGE ranks N+1 N+6
,Lao Wang’s last 5 are:
ZRANGE ranks N-6 N-1
.To put it all together, plus Lao Wang himself, it is:
ZRANGE ranks N-6 N+6
.Note: You must remember to first determine whether N-6 and N-1 are less than 0.