Dev HelpersOpen library
← Back

Compare human-readable numbers

Compare human-readable numbers. A self-contained example using the JavaScript runtime.

Open this example in the interactive library

Source code

const collator = new Intl.Collator("en", { numeric: true });
console.log(["file10", "file2", "file1"].sort(collator.compare));

Sample output

[ 'file1', 'file2', 'file10' ]