A Sorted Set is very similar to a Set, but each element of a Sorted Set has an associated score. In other words, a Sorted Set is a collection of nonrepeating Strings sorted by score. It is possible to have elements with repeated scores. In this case, the repeated elements are ordered lexicographically (in alphabetical order).
Sorted Set operations are fast, but not as fast as Set operations, because the scores need to be compared. Adding, removing, and updating an item in a Sorted Set runs in logarithmic time, O(log(N)), where N is the number of elements in a Sorted Set. Internally, Sorted Sets are implemented as two separate data structures:
A skip list with a hash table. A skip list is a data structure that allows fast search within an ordered sequence of elements.
A ziplist, based on the zset-max-ziplist-entries and zset-max-ziplist-value configurations.
Note
Chapter 4, Commands (Where the Wild Things Are), provides more details about these configurations.