My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SortCommand  
Updated Dec 21, 2010 by anti...@gmail.com

We moved to Redis.io!

Redis home moved to http://redis.io, please visit our new home.

Comment by enaes...@gmail.com, Dec 20, 2009

What is the time complexity of SORT?

Comment by tongxiao...@gmail.com, Jan 9, 2010

if can support SORT SINTER key1 key2 key3 . redis will can make a search engine.

Comment by vita...@gmail.com, Aug 1, 2010

We already heave a {weight} in sorted lists, so it whould be nice to have a sorting by {weight} from sorted lists, for example: SORT mylist BYSCORE weight

Comment by manchesterboy, Sep 8, 2010

multiple by would be lovely (blush)

Comment by chick.t...@gmail.com, Sep 21, 2010

@tongxiaojun, already exists with a little cleverness

1. SINTERSTORE tmp_key key1 key2 key3... (also SDIFFSTORE and SUNIONSTORE)

2. SORT tmp_key BY ... GET ...

3. DEL tmp_key

Comment by case...@gmail.com, Oct 1, 2010

I think it will be userful to add "SORT key RANDOM" option to get N random and non-repeating values from SET.

Comment by lamef...@gmail.com, Oct 15, 2010

it would be useful to sort on fixed properties of an external key , i'm thinking of cardinality

who_owns_cars_list : bob john matt jack jill

jill_cars : porsche matt_cars: audi ford chevy jack_cars: toyota ford

who owns the most cars?

SORT who_owns_cars list BY cardinality ( cars )

thanks !

LOVE redis btw

Comment by lamef...@gmail.com, Oct 15, 2010

oops my star disappeared - that was of course SORT who_owns_cars list BY cardinality (<STAR>cars )

Comment by thomasknowles, Nov 12, 2010

I may be doing this wrong but here is my scenario, I have a list of timestamps:

redis> lpush time_list 1234567892 (integer) 1 
redis> lpush time_list 1234567893 (integer) 2 
redis> lpush time_list 1234567894 (integer) 3 
redis> lpush time_list 1234567895 (integer) 4
redis> sort time_list by nosort 
1. "1234567895" 
2. "1234567894" 
3. "1234567893" 
4. "1234567892"

and a list of values in a hash with associated timestamps:

redis> hset value 1234567892 12 
(integer) 1 
redis> hset value 1234567893 15 
(integer) 1 
redis> hset value 1234567894 16 
(integer) 1 
redis> hset value 1234567895 16 
(integer) 1

Now I understand that I can use BY/GET and reference keys using the *, however, would it be possible that it could be implemented to use fields (within hashes) aswell. So I could implement:

sort time_list by nosort GET value->`*`

So that all of the values which I sort through in the list "time_list" will then be referenced against the fields found within the hash and then GET the results. I know that I could simply use normal key-value pairs however, I was hoping I could take advantage of the nicely coupled hashes, if anyone has any other ideas then please let me know.

Comment by zimpenf...@gmail.com, Dec 3, 2010

"Note that GET can be used multiple times"

This doesn't appear to be the case when using the -> syntax for hash fields.

redis> sort hashes get p*->fish 
1. "carp"
2. "roach"
3. "lemon"
redis> sort hashes get p*->fish p*->size
(error) ERR syntax error
Comment by lior.sa...@gmail.com, Dec 14, 2010

Sorting on shrded weight keys would be nice!

"With SORT BY you need that all the weight keys are in the same Redis instance of the list/set you are trying to sort"

This limits my sharding strategy. Would be nice to be able using the key tags for sorting over sharded weight keys that are not necessarily stored on the same Redis instance of the list

Comment by marc.see...@gmail.com, Dec 21, 2010

Can the "get" operator access other databases? (usually switched to with "select")


Sign in to add a comment
Powered by Google Project Hosting