From: "Wolfgang Nádasi-Donner" Date: 2007-10-28T00:25:28+09:00 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 Nádasi-Donner -- Posted via http://www.ruby-forum.com/.