antirez/redis — Issue #227: SORT ... STORE does not behave like other *STORE commands
Author: orend
Created: 2011-12-01 16:55:28+00:00
State: open

Commands such as SINTERSTORE overwrite existing values for the destination, *even if the result of the operation is an empty set/list*. SORT overwrites existing values as well, with one subtle difference: if the result of sort is an empty list *the value is not overwritten*. This behavior is very confusing, and IMO should be changed or at least be clearly documented.

Here's an example:

```redis
redis 127.0.0.1:6379> lpush mylist a
(integer) 1
redis 127.0.0.1:6379> lpush mylist b
(integer) 2
redis 127.0.0.1:6379> lpush mylist c
(integer) 3
redis 127.0.0.1:6379> sort mylist store temp
(integer) 3
redis 127.0.0.1:6379> lrange temp 0 2
1) "c"
2) "b"
3) "a"
redis 127.0.0.1:6379> sort emptylist store mylist
(empty list or set)
redis 127.0.0.1:6379> lrange temp 0 2
1) "c"
2) "b"
3) "a"
```

Note that the SORT command documentation does not even mention that the destination will be overwritten.