<pre id="output"></pre>
pre {font-family: 'Monaco', 'Consolas', 'Courier New', sans-serif;}
pre strong {font-weight: 700; color: #f90;}
var collator = new Intl.Collator(undefined, {
numeric: true,
sensitivity: "base"
});
var myArray = ["1_Document", "11_Document", "2_Document"];
document.getElementById("output").innerHTML = "<strong>First Example</strong>:\n" + JSON.stringify(myArray.sort(collator.compare), null, 2);
document.getElementById("output").innerHTML += "\n\n<strong>Second Example</strong>:\n";
ourArray = ["123asd", "19asd", "12345asd", "asd123", "asd12"];
document.getElementById("output").innerHTML += JSON.stringify(ourArray.sort(collator.compare), null, 2);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.