Demystifying the Array.prototype.sort Comparator
While patching a legacy Beego dashboard I stumbled on a tiny sorting requirement that refused to cooeprate. The goal sounded trivial: given an array that mixes one-, two- and three-digit integers, keep the global ascending order but push every two-digit value to the tail.
const sample = [1, 8, 3, 11, 100, 15, 201];
// expected: [1, 3, 8, 100, 2 ...
Posted on Sun, 17 May 2026 08:30:11 +0000 by dolphinsnot