JS Number Sorting
I don’t know how I missed this. JavaScript’s sort is lexical, so it’s totally whack for numbers.
[10, 2, 200].sort()
[ 10, 2, 200 ]
The quick fix for ascending order is
[10, 2, 200].sort((a, b) => a - b)
[ 2, 10, 200 ]
Has it been so long since I sorted a simple list of numbers?!