Input:
[2,"x","y",7, 0.5, "z", 0.9, 3, 4, "a", "d", 0.1, 6.5, 12, 56,"c","m",0.3 ,"p", "q", 8, 9]
Output:
["x", "y", "z", "a", "d", "c", "m", "p", "q", 0.5, 0.9, 0.3, 6.5, 0.1, 9, 7, 3, 4, 12, 56, 8, 9]
function sorter(arr) {
var arr1, arr2, arr3;
arr1 = [];
arr2 = [];
arr3 = [];
for (var i = 0; i < arr.length; i++) {
if (typeof arr[i] === "string") {
arr1.push(arr[i]);
} else if (typeof arr[i] === 'number' && !isNaN(arr[i])) {
if (Number.isInteger(arr[i])) {
arr3.push(arr[i]);
} else {
arr2.push(arr[i]);
}
}
}
return [...arr1, ...arr2, ...arr3];
}