Sorting of strings is different in IronRuby than in Ruby

Hi

I was playing around with a very simple code example and got different
results in IronRuby and in Ruby.

“IronRuby In Action”.split(//).sort.uniq.join

returns in MRI: " AIRbcinortuy"
returns in IronRuby: " AbciInorRtuy"

I’m sure you guys are aware of this, but just in case :slight_smile:
I guess in the end the 2 results should be the same or is this perhaps
something that has to do with encoding?

Cheers
Ivan

We end up calling String.CompareTo which performs a lexicographical
comparison. This is the source of the different behavior. This should
be filed as a bug in RubyForge if it hasn’t been already.

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Wednesday, August 20, 2008 12:54 AM
To: [email protected]
Subject: [Ironruby-core] sorting of strings is different in IronRuby
than in Ruby

Hi

I was playing around with a very simple code example and got different
results in IronRuby and in Ruby.

“IronRuby In Action”.split(//).sort.uniq.join

returns in MRI: " AIRbcinortuy"
returns in IronRuby: " AbciInorRtuy"

I’m sure you guys are aware of this, but just in case :slight_smile:
I guess in the end the 2 results should be the same or is this perhaps
something that has to do with encoding?

Cheers
Ivan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs