I was doing some administration in the awful BillToBox (seriously not happy with this “solution”, but that’s another topic for another day), and to try and make sense of my uploaded documents I sorted them by name:
Look at the “Naam van he…” column.
What the hell is going on with this sorting? 82, 83, 86, 85, 84? Hu? (Expected behaviour is 86, 85, 84, 83, 82…)
In which world does this make any sense? It doesn’t even seem to be a case where they forgot to implement natural sort order – it’s just… wrong?
This Svelte REPL shows a quick implementation of natural sort order sorting. Jeff from CodingHorror explains the problem in this 2007 blog post.
Reminds me to maybe go for a tried and tested solution instead of reinventing the wheel when we revamp filtering & sorting in my current project… as there are always lots of things you don’t think about, until you encounter the problem.
1 Comment
I’ve never seen natural sorting work well. It’s often a remnant from junior developers discovering it in the PHP API and thinking it will solve all their problems. Save yourself the trouble and use (case-insensitive) bog-standard lexicographic ordering.