I do not know if it is possible with common methods of ordering, on account of the natural ordering of the elements.
If you take a test, how:
var lista = ['1', '4', 'C', '6', '2', 'A'];
function OrdenarArray(a, b) {
return a > b;
}
will have a result: ['1', '2', '4', '6', 'A', ...]
I ordered with a certain effort:
var lista = ['10', '4', 'C', '6', '2', 'A'];
function OrdenarArray(a, b) {
return a > b;
}
var lLetras = new Array();
var lNumeros = new Array();
$.each(lista, function(indice, obj) {
if (!isNaN(parseInt(obj, 0)))
lNumeros.push(Number(obj));
else
lLetras.push(obj);
});
lLetras = lLetras.sort(OrdenarArray);
lNumeros = lNumeros.sort(OrdenarArray);
lista = lLetras;
$.each(lNumeros, function(indice, obj) {
lista.push(obj.toString());
});
Final result: ['A', 'C', '2', '4', ...]
Of course there must be better ways to sort. Ah, and I used jquery. = x
Using
10
does not work: https://jsfiddle.net/Lkpscrf8/1/– Sergio
Ready, @Sergio. https://jsfiddle.net/Lkpscrf8/5/
– Aline