Это реализация https://stackoverflow.com/a/4673436/1258486 для CoffeeScript.
https://gist.github.com/eces/5669361
if String.prototype.format is undefined
String.prototype.format = () ->
_arguments = arguments
this.replace /{(\d+)}/g, (match, number) ->
if typeof _arguments[number] isnt 'undefined' then _arguments[number] else match
Вы могли сделать это в одной строке с помощью String.prototype.localCompare()
и получить результат, который Вы ищете. Обратите внимание, что числовое сопоставление опция включена.
var arr = [1,5,"ahsldk",10,55,3,2,7,8,1,2,75,"abc","huds"];
arr.sort((a,b) => ("" + a).localeCompare(b, undefined, {numeric: true}));
console.log(arr);
// [1, 1, 2, 2, 3, 5, 7, 8, 10, 55, 75, "abc", "ahsldk", "huds"]
, Возможно, добавляют, что некоторая логика для обработки аннулирует.