You are comparing Strings which do not have a particular order like numbers.
If the strings really always only contain digits 0,1,2,3,4,5,6,7,8,9
you can convert them into integers. And with the integers you can do
compare ">" greater than or "<" smaller than
Yes they do. The String class overloads comparison operators. Amongst others.
void setup() {
Serial.begin(115200);
String x = "abc";
String y = "def";
String z = "ghi";
Serial.print(y);
if (y > z)
Serial.print(" is greater than ");
else
Serial.print(" is less than ");
Serial.println(z);
Serial.print(y);
if (y > x)
Serial.print(" is greater than ");
else
Serial.print(" is less than ");
Serial.println(x);
}
void loop() {
// put your main code here, to run repeatedly:
}