I have a sorted set in Redis with priorities starting from 0 up to 3. I would like to traverse this sorted set from highest to lowest priority using the python iterator zscan_iter
. However, using zscan_iter
gives me the items starting from 0. Is there a way to reverse the order? Unfortunately, reverse()
only works on iterators and not on python generators.
I see two solutions:
ZREVRANGEBYSCORE
, however I would prefer to use an iterator.Are there any other ways of doing this?
Scanning the Sorted Set with an iterator does not guarantee any order. Use ZREVRANGEBYSCORE
for that.