JavaScript has a built-in sort() function, you can use it like this: var numbers = [6, 2.7, 8]; numbers.sort(); // => [2.7, 6, 8] ...oh, totally forgot to mention, it sorts in lexicographic order, i.e. 10 < 9 and 9 < -100. Probably that's what you expect anyway.