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

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -