I'm getting an error when attempting to use the spaceship operator with non alpha-numeric characters in the sort function.
word = "out-classed"
letters = word.downcase.split('')
letters.sort! do |x, y|
if y < 'a'
next
else
value = x <=> y
end
end
I'm getting ArgumentError: comparison of String with String failed, and I'm almost positive this happens with the spaceship operator and not the < comparison.
The interesting part is that when I do this same comparison in irb outside of the context of a sort block, the comparison works. It also works when the word variable only consists of letters.
Can anybody help me to understand why this doesn't work in this specific context alone?