Why 100 Sorts Before 99
luljs still worksAs text, "100" is less than "99", but as numbers it is not.
In 2026: Still works. When both operands are strings, < compares them character by character by code point, like dictionary order. "1" comes before "9", so "100" < "99" is true. As numbers the comparison flips. This is why a plain string sort puts file10 before file9.
Where it came from: With two string operands, < compares code point by code point, MDN's less-than page notes, so "100" orders before "99". MDN ↗
<script>
document.write('<p><code>"100" < "99"</code> is <b>' + ("100" < "99") + '</b> (compared as text)</p>');
document.write('<p><code>100 < 99</code> is <b>' + (100 < 99) + '</b> (compared as numbers)</p>');
document.write('<p>Strings compare character by character, so "1" sorts before "9".</p>');
</script>