Since A comes before a in ASCII table, so S in Spam is considered smaller than e in eggs.
>>> "A" < "a"
True
>>> "S" < "e"
True
>>> "S" < "eggs"
True
Note that, String length in not considered in comparison. Rather ordinal values for each byte are compared starting from the first byte, as rightly pointed out by @MikeGraham in comments below.
And as soon as mismatch is found, the comparison stops, and comparison value is returned, as in the last example.
From the docs - Comparing Sequences and Other Types: -
The comparison uses lexicographical ordering: first the first two
items are compared, and if they differ this determines the outcome of
the comparison; if they are equal, the next two items are compared,
and so on, until either sequence is exhausted.
Also further in the same paragraph: -
Lexicographical ordering for strings uses the ASCII ordering for
individual characters