vendredi 29 mai 2015

Javascript sort() array of mixed data type

If I have an array like:

["23", "765", "sfasf", "2.3E-3", "2.3cE-3"]

How can I order it so numbers(decimals, floats or scientific notation) are ordered ascending and after those strings that aren't numbers(for example "sfasf" or "2.3cE-3")?

Expected order of the example array:

["2.3E-3", "23", "765", "2.3cE-3", "sfasf"]

Aucun commentaire:

Enregistrer un commentaire