It compares the character code values of the strings, returning -1 (less than), 0 (equals), or 1 (greater than), depending on the comparison, which is case-sensitive "a" <=> "a" # => 0 "a" <=> 97.chr # => 0 "a" <=> "b" # => -1 "a" <=> "'" # => 1