sorting - redis sort by multi fields -


it's easy use sql query multi sort fields.for example:

select * user order score desc,name desc 

with 2 fields sort(score,name).

how should in redis?

use sorted set of redis sorted score. have prepare score according needs.

finalscore = score*max_name_value + getintrepresentation(name)  //max_name_value maximum value returned getintrepresentation() method 

and use

 zadd myset finalscore value 

and use

zrevrange myset 0 10 

Comments

Popular posts from this blog

pentaho - Carte Status / Kettle Slave Server Status page shows status for random runs instead of the latest run -

c - sscanf() double showing zeros -