Javascript - sorting arrays containing positive and negative "decimal" numbers
Posted
by hhj
on Stack Overflow
See other posts from Stack Overflow
or by hhj
Published on 2010-06-02T19:41:45Z
Indexed on
2010/06/02
19:44 UTC
Read the original article
Hit count: 401
I originally had the following callback passed as a parameter to the javascript array sort()
function:
function sortNumber(a,b) {
return a-b;
}
However this doesn't work when my array contains positive and negative decimal numbers (i.e. -107.578, 97.453 etc.) How would I modify this to sort properly?
© Stack Overflow or respective owner