Redis.sort

Sort a Set or a List accordingly to the specified parameters. <p> <b>examples:</b> <p> Given are the following sets and key/values:

<pre> x = [1, 2, 3] y = [a, b, c]

k1 = z k2 = y k3 = x

w1 = 9 w2 = 8 w3 = 7 </pre>

Sort Order:

<pre> sort(x) or sort(x, sp.asc()) -&gt; [1, 2, 3]

sort(x, sp.desc()) -&gt; [3, 2, 1]

sort(y) -&gt; [c, a, b]

sort(y, sp.alpha()) -&gt; [a, b, c]

sort(y, sp.alpha().desc()) -&gt; [c, a, b] </pre>

Limit (e.g. for Pagination):

<pre> sort(x, sp.limit(0, 2)) -&gt; [1, 2]

sort(y, sp.alpha().desc().limit(1, 2)) -&gt; [b, a] </pre>

Sorting by external keys:

<pre> sort(x, sb.by(w*)) -&gt; [3, 2, 1]

sort(x, sb.by(w*).desc()) -&gt; [1, 2, 3] </pre>

Getting external keys:

<pre> sort(x, sp.by(w*).get(k*)) -&gt; [x, y, z]

sort(x, sp.by(w*).get(#).get(k*)) -&gt; [3, x, 2, y, 1, z] </pre> @see #sort(string) @see #sort(string, SortingParams, string) @param key @param sortingParameters @return a list of sorted elements.

Meta