JSFiddle - React, Tailwind, and code Playground
JavaScript
var array = ["31ab12", "20a40", "11abc27"];
array.sort(function(a,b) {
function getEndNum(str) {for (var i=str.length-1; i>=0; --i) {if (isNaN(str.charAt(i))) {return str.substring(i+1);}}} //this function returns the end-number of the supplied string
return getEndNum(b) - getEndNum(a); //sort array descendingly, based on the end-numbers
});
console.log(array.map(function(a){return parseInt(a);})); //create a new array with only the start-numbers