Fix zero-ordering SORT when called against lists

People mostly use SORT against lists, but our prior
behavior was pretending lists were an unordered bag
requiring a forced-sort when no sort was requested.

We can just use the native list ordering to ensure
consistency across replicaion and scripting calls.

Closes #2079
Closes #545 (again)
This commit is contained in:
Matt Stancliff
2014-10-23 11:52:35 -04:00
committed by antirez
parent e1524f5010
commit 77bbc0dfad
2 changed files with 24 additions and 9 deletions

View File

@ -246,6 +246,24 @@ start_server {
r sort mylist by num get x:*->
} {100}
test "SORT by nosort retains native order for lists" {
r del testa
r lpush testa 2 1 4 3 5
r sort testa by nosort
} {5 3 4 1 2}
test "SORT by nosort plus store retains native order for lists" {
r del testa
r lpush testa 2 1 4 3 5
r sort testa by nosort store testb
r lrange testb 0 -1
} {5 3 4 1 2}
test "SORT by nosort with limit returns based on original list order" {
r sort testa by nosort limit 0 3 store testb
r lrange testb 0 -1
} {5 3 4}
tags {"slow"} {
set num 100
set res [create_random_dataset $num lpush]