HN Hall of Fame Weekly email

User-defined Order in SQL

begriffs.com Books & learning Tutorials & guides Software engineering Candidate
Screenshot of begriffs.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 4 calendar years, with breakout response in 2 of them.

submissions
4
submitters
4
observed span
2018–2024
peak thread · 134 comments
314 pts
latest 20+ return · 2024-08-12
22 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Having run into this problem a few times now, Approach 1 is unfortunately best. Two reasons: (1) If updates fail, you don't get a resulting broken state (2) The size of the lists is not that large (<50), so the extra writes are not that expensive. Essentially, with any variation on fractional updates (where only 1-2 rows are updated per list update), the client is sending to the server "move item a to position x". Then, shortly after, "move item…

cthor·314-point thread·

There's a no-free-lunch theorem here that's being ignored. If you have a space of 64 bits to represent elements of some ordered field, and you insert items one at a time, there is some ordering of the items that allows you to make only 64 inserts. Claiming that numbering the items with integers only allows you 16 insertions, but "It would take virtually forever to run out of space through repeated list reordering" using rational numbers just can't be correct…

dmurray·136-point thread·

Whenever I see this discussion come up my question is always: Why do you want to manually sort a giant list? I have never needed this. For smaller lists at the human scale (<1000 items), just use an integer. For larger lists no human should have to manually sort those anyway. Find some computational way of presenting the data to the human.

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
477

reference only — not used in Hall rules or ranking

Total comments
238

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2018-03-21User-defined Order in SQLFirst breakout · Best threadgrzm314134
2021-01-15The surprisingly difficult problem of user-defined order in SQLccmcarey13693
2023-08-23User-Defined Order in SQLthunderbong50
2024-08-12User-defined Order in SQL (2018)Latest 20+ point returnpassword43212211