In production, a sorted set holds the scores
The scores live in a shared store, not in one process's memory. Redis has a type made for this: the sorted set. Each member has a score, adding or changing one is O(log n), and you can read members in order by rank.
The order has the same trap as reverse=True. Redis's docs say members with the same score are ordered lexicographically, from A to Z. Read from highest score to lowest, with ZREVRANGE or ZRANGE with REV, and ties come out in descending lexicographical order, from Z to A. That's Maple before Harbor again.
The same fix works. Store each score negated and read with plain ZRANGE: the highest score comes first, and ties stay from A to Z.
The rest of the design follows from the two lists:
- One sorted set holds the catalog's scores, shared by every server.
- Each viewer's state is small: which titles they've seen this loop, or a cursor plus a version of the ranking.
- Scores change through
updatecalls from a scoring job. Writing the new score to the sorted set is the whole update.
The editor holds zrange, zrevrange and billboard. Write the first two the way Redis orders members, then billboard(scores) from zrange with negated scores.