• antirez's avatar
    "SORT by nosort" (skip sorting) respect sorted set ordering. · 2ba96271
    antirez authored
    When SORT is called with the option BY set to a string constant not
    inclduing the wildcard character "*", there is no way to sort the output
    so any ordering is valid. This allows the SORT internals to optimize its
    work and don't really sort the output at all.
    
    However it was odd that this option was not able to retain the natural
    order of a sorted set. This feature was requested by users multiple
    times as sometimes to call SORT with GET against sorted sets as a way to
    mass-fetch objects can be handy.
    
    This commit introduces two things:
    
    1) The ability of SORT to return sorted sets elements in their natural
    ordering when `BY nosort` is specified, accordingly to `DESC / ASC` options.
    2) The ability of SORT to optimize this case further if LIMIT is passed
    as well, avoiding to really fetch the whole sorted set, but directly
    obtaining the specified range.
    
    Because in this case the sorting is always deterministic, no
    post-sorting activity is performed when SORT is called from a Lua
    script.
    
    This commit fixes issue #98.
    2ba96271
sort.tcl 9.24 KB