Why does this sort the numbers? numbers = input.match(/[+-]?\d+(\.\d+)?/g).map(Number)