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<b ? no. b<c? yes. -> c is 'greater' than b, therefore ca < bb -> false.
console.log('ba'<'bb');//true
It starts with b<b ? no. b > b? no. They both equal -> continue to next letter.
a < b ? yes. Therefore -> ba < bb -> true.
WIKI