I'm trying to compare two arrays in javascript.
What I'd like is:
a < b ⇔ ∃ i ≥ 0 s.t. a[i] < b[i] and ∀ 0 ≤ j < i, a[j] = b[j]
So arrays of non-negative numbers work as desired:
firebug> [0,1,2,3,4] < [1,0,0]
true
And comparing negative numbers with zero works as expected:
firebug> [-1, 1] < [0, 0]
true
But comparing negative numbers with negative numbers is... suprising:
firebug> [-2] < [-1]
false
firebug> -2 < -1
true
What's going on here, so I can correct my intuition for what array comparison means in javascript?