Ruby | String <=> Method
<=>() is a String class method in Ruby which is used for comparisons of the strings. This method returns -1, 0, +1, or nil depending on whether the specified string is less than, equal to, or greater than other_string.
Syntax: str other_string
Parameters: Here, str and other_string are the strings which are compared.
Returns: Returns nil if the two specified values are incomparable.
Note: The longer string is considered greater than the shorter one if the specified strings are of different lengths, and the strings are equal when compared up to the shortest length,