unsubscribe

-----Original Message-----
From: list-bounce / example.com [mailto:list-bounce / example.com] On Behalf Of Wolfgang Ndasi-Donner
Sent: 27 October 2007 16:25
To: ruby-talk ML
Subject: Re: Error in Ruby text comparison?

Greg Willits wrote:
> '1sqHmb5b8G9mN' < '1Xv5LeB9bMdar'
> 
> Wouldn't you think that is supposed to be TRUE ?
> 
> All my text editors and Excel and Numbers all sort it so that 1s...
> comes before 1X...
> 
> But Ruby says the above comparison is false.
> 
> What am I missing?
> 
> -- gw

Ruby - like several other languages - makes the comparison based on the 
underlying code. When you only have English texts it may be confusing, 
because you expect a different behavior.

I think it is always a bad idea to compare texts in this way, because 
the character sequence is first based on language definitions (e.g. 
letter "" is in German the same lake "oe", while in Swedish it comes 
after "z"), and second for a language there may be different standards 
too (e.g. telefone book sequence versus language definition sequence, as in German).

If You want to compare Strings based on the usage in a language, you 
should better use an appropriate sequence definition.

Wolfgang Ndasi-Donner
-- 
Posted via http://www.ruby-forum.com/.