Does anyone know how the built-in JS function array.sort()
functions internally? I mean does it change strings to numbers....etc
var keys = new Array();
keys.sort();
Does anyone know how the built-in JS function
|
||||
From the MDN docs for sort():
Refer to the answers of this question as to what algorithm is being used. |
|||||
|
new Array
is evil, use[]
literal syntax instead. – hugomg Nov 8 '11 at 20:24.sort
will not change any element values, unless you specify a function which modifies the input. eg:keys.sort(function(x,y){x.moo=1337; y.cowsay="bar";})
– Rob W Nov 8 '11 at 20:30