It's an alphabetical comparison (AIUI the sort order may be influenced by the current locale). It compares the first character of each string, and if the one on the left has a higher value it's true, if lower it's false; if they're the same, then it compares the second character, etc.
This is not the same as integer comparison, for that you use [[ 2 -gt 1 ]]
or (( 2 > 1 ))
. To illustrate the difference between string and integer comparison, consider that all of the following are "true":
[[ 2 > 10 ]] # because "2" comes after "1" in ASCII sort order
[[ 10 -gt 2 ]] # because 10 is a larger number than 2
(( 10 > 2 )) # ditto
Here are some more test that're true as string comparisons, but would be false with integer comparison:
[[ 05 < 5 ]] # Because "0" comes before "5"
[[ +5 < 0 ]] # Because "+" comes before the digits
[[ -0 < 0 ]] # Because "-" comes before the digits
[[ -1 < -2 ]] # Because "-" doesn't change how the second character is compared