I was under the impression that in order to sort an array of numbers you had to do the following:
var numbers = [4, 1, 2, 3];
function compare(a, b) {
retur
It seems to work in all cases for me.
You have not considered any cases of numbers that consist of multiple digits in string representation. The lexicographic default comparison also fails on negative numbers.
See How to sort an array of integers correctly for more information and some counterexamples.