JSFiddle - React, Tailwind, and code Playground
by pseudosavant
HTML
<div id="result></div>
JavaScript
var a = ["10", "11", "12", "13", "2", "3", "4", "5", "6", "7", "8", "9", "2a", "2s", "3a"];
var numericAlphaSort = function(a, b){
// <0 = a should be lower indexed than b
// 0 = a are equal b, no sorting
// >0 = a should be higher indexed than b
var bothNumbers = (a == +a && b == +b);
if (bothNumbers) {
return (a - b);
} else {
}
};
a = [1,5,3,4,6,8,9];
var result = a.sort(numericAlphaSort).toString();
$("#result").html(result);