tie breaker
A final unique field, usually the identifier, added to a sort order so items with equal values always come out in the same order.
In more detail
Without a tie breaker, items with equal keys can come out in an unpredictable order, which makes pagination and tests unstable. A unique value such as an ID or an insertion counter is the usual choice.
Example
Heap entries (priority, counter, task) use the counter to break ties so tasks are never compared.Related terms
- lexicographic order — Ordering sequences the way a dictionary orders words: compare the first elements, and only if they are equal move on to the next.
- priority queue — A collection where each item has a priority and the item removed next is always the one with the highest priority, not the oldest.
- stable sort — A sort that keeps items with equal keys in the same relative order they had before sorting.
- sort key — The field a collection is ordered by, chosen by the client from a small documented list, such as sort=title or sort=-id for descending.
- cursor pagination — Paging by remembering the position of the last item seen and asking for items after it, such as ?after=2&limit=2.
- stable ordering — An order of results that is the same every time the same request is made, which pagination depends on.
- ORDER BY — The clause that sorts a query's answer by one or more columns, each ascending or descending.
- ROW_NUMBER — A window function that numbers rows 1, 2, 3 in the window's order, giving tied rows different numbers.
- keyset pagination — Paging by remembering the last key the reader saw and asking for rows after it, which does not drift.
Taught in
- Sorting In Real Systems: Stability, Keys And External Sort — Algorithms & Data Structures for Working Engineers
- Pagination Strategies — Modern API Architecture: REST, GraphQL & gRPC
- Sorting Results — Modern API Architecture: REST, GraphQL & gRPC
- Advanced Window Functions: Ranking And Framing — PostgreSQL, Indexing & Relational Data Modeling