It's a lexicographic
comparsion.
It starts with the first letter and goes on until a mismatch.
console.log('ca'<'bb'); //false
It starts with c c is 'greater' than b, therefore ca < bb -> false.
console.log('ba'<'bb');//true
It starts with b b? no. They both equal -> continue to next letter.
a < b ? yes. Therefore -> ba < bb -> true.
WIKI