The trick is that string comparison should be case-insensitive. "Hello" and "HELLO" should compare as equal. Convert both strings to the same case (all lowercase or all uppercase) before comparing.
Then use standard lexicographic comparison. Lexicographic comparison works character by character. The first position where characters differ determines the result. If one string is a prefix of the other, the shorter one comes first.