We have already learned in Chapter 2, Data Types that elements in a Redis list or set are unordered, and elements in a Redis sorted set are ordered by their scores. Sometimes we may need to get a sorted copy of a Redis list or set in some order, or sort elements in a Redis sorted set by an order other than scores. Redis provides a convenient command called SORTÂ for this purpose. In this recipe, we will take a look at the SORTÂ command and its examples.
Using SORT
Getting ready…
You need to finish the installation of the Redis Server as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.