4 ms·
Lexicographic ordering of two arrays X and Y is (I think) the standard ordering of arrays. Algorithm something like (pseudocode, ignoring different length array
by CJefferson 11y ago
Lexicographic ordering of two arrays X and Y is (I think) the standard ordering of arrays. Algorithm something like (pseudocode, ignoring different length arrays):
for(i = 0; i < length(X); ++i) {
if(X[i] < Y[i]) X is smaller
if(X[i] > Y[i]) Y is smaller
}
arrays are equal!
In every programming language I've ever used (other than Javascript), the following is how arrays are ordered (well, except for languages like C, where they are compared by memory location by default)
[1,1] < [2,2] < [11,11] < [22,22]
Instead Java says [1,1] < [11,11] < [2,2] < [22,22], because it compares the arrays as strings.