Redis 排序

命令 : SORT

用例和描述 : SORT source-key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE dest-key] —— 根据给定的选项,对输入的列表集合或者有序集合进行排序,然后返回或者存储排序的结果

 

例子 :

127.0.0.1:6379> rpush sort-input 23 15 110 7
(integer) 4
127.0.0.1:6379> sort sort-input
1) "7"
2) "15"
3) "23"
4) "110"
# 根据字母表顺序排序
127.0.0.1:6379> sort sort-input alpha
1) "110"
2) "15"
3) "23"
4) "7"
127.0.0.1:6379> hset d-7 field 5
(integer) 1
127.0.0.1:6379> hset d-15 field 1
(integer) 1
127.0.0.1:6379> hset d-23 field 9
(integer) 1
127.0.0.1:6379> hset d-110 field 3
(integer) 1
127.0.0.1:6379> sort sort-input by "d-*->field"
1) "15"
2) "110"
3) "7"
4) "23"
127.0.0.1:6379> sort sort-input by "d-*->field" get "d-*->field"
1) "1"
2) "3"
3) "5"
4) "9"

 

 

 

posted on 2018-03-08 19:22  _路上  阅读(125)  评论(0编辑  收藏  举报

导航