英[sɔ:t] 美[sɔ:rt]
n.Classification, category; quality, nature; method; a group
vt.& vi.Classification; rectification, arrangement ; suitable for
vt. to select; to classify; to put in order
vi. to classify; to communicate; to coordinate
Third person singular: sorts Plural: sorts Present participle: sorting past tense: sorted past participle: sorted
redis SORT command syntax
Function: Return or save the sorted elements in a given list, set, or ordered set key. Sorting defaults to numbers as objects, values are interpreted as double-precision floating point numbers and then compared.
Syntax: SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA] [STORE destination]
Available versions: >= 1.0.0
Time complexity: O(N M*log(M)), N is to be sorted The number of elements in the list or set, M is the number of elements to be returned. If you just use the GET option of the SORT command to obtain the data without sorting, the time complexity is O(N).
Return: Without using the STORE parameter, the sorted result in list form is returned. Use the STORE parameter to return the number of elements in the sorted result.
redis SORT command example
# 开销金额列表 redis> LPUSH today_cost 30 1.5 10 8 (integer) 4 # 排序 redis> SORT today_cost 1) "1.5" 2) "8" 3) "10" 4) "30" # 逆序排序 redis 127.0.0.1:6379> SORT today_cost DESC 1) "30" 2) "10" 3) "8" 4) "1.5"