# Sorting of strings is different in IronRuby than in Ruby

**URL:** <https://www.ruby-forum.com/t/sorting-of-strings-is-different-in-ironruby-than-in-ruby/146358>\
**Category:** IronRuby\
**Created:** [August 20, 2008, 9:54am UTC](https://www.ruby-forum.com/t/sorting-of-strings-is-different-in-ironruby-than-in-ruby/146358 "2008-08-20T09:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [August 20, 2008, 9:54am UTC](https://www.ruby-forum.com/t/sorting-of-strings-is-different-in-ironruby-than-in-ruby/146358/1 "2008-08-20T09:54:38Z")

</div>

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 🙂  
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

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [August 21, 2008, 1:27am UTC](https://www.ruby-forum.com/t/sorting-of-strings-is-different-in-ironruby-than-in-ruby/146358/2 "2008-08-21T01:27:56Z")

</div>

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: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Ivan Porto  
Carrero  
Sent: Wednesday, August 20, 2008 12:54 AM  
To: removed\_email\_address@domain.invalid  
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 🙂  
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
