Redis-How to sort non-numeric elements using the sort command

The SORT command can sort the list type, collection type, and ordered collection type keys.

The elements in the list are numbers

Operation example: The Insert picture description here
elements are numbers, and the ordered results are returned through the sort command list.

The elements in the list are non-digits

Operation example: Insert picture description here
directly report an error, see the result of the error report, it is impossible to convert to double type, the error is reported. This is because the SORT command will try to convert elements into double-precision floating-point numbers for comparison. Letters cannot be converted into double types, so an error will naturally be reported.

Solution, plus ALPHA parameters

Operation example: It Insert picture description here
can be found that the letters can be sorted normally.

Guess you like

Origin blog.csdn.net/weixin_38106322/article/details/108500590