I have a var which takes an array of values, these values are either alphanumeric or numbers but as alphanumerics, the question is what's the most efficient way to apply sorting based on the values? I want alphabetical sorting for the alphanumeric values and ascending order when it contains numbers.
By far i know that
var myArr=['c','a','b']
myArr.sort(); //gives output a,b,c
and if later on:
myArr=['10','1','2'];
myArr.sort();// gives 1,10,2
but is there a fast way to decide which method of sorting to use based on the array's contents?
Thanks in advance!