From: Johan Holmberg Date: 2009-05-20T15:04:27+09:00 Subject: Re: Sorting numbers as strings On Wed, May 20, 2009 at 6:24 AM, Rob Biedenharn wrote: > On May 19, 2009, at 5:51 PM, Johan Holmberg wrote: >> >> On Tue, May 19, 2009 at 5:24 PM, Jack Bauer >> wrote: >>> >>> You guys are great. I went with Bob's (pick one, hah) since it ended up >>> being moderately faster than the method I was originally using. >>> -- >> >> Here is a variant similar to the other solutions you already got: >> >>   puts arr.sort_by {|s| s.split(/(\d+)/).each_with_index.map {|x,i| >> i.odd? ? x.to_i : x }} >> >> Works with Ruby 1.9. >> >> /Johan Holmberg > > > Are you trying to say that you believe some part of a solution that Jack > already accepted won't work in Ruby 1.9? (Because they should work fine.) > > -Rob > No, not at all. I tried to say that I believed *my* variant only worked in 1.9 (and maybe 1.8.7). (I should have said "Only works with Ruby 1.9"). Sorry for the misunderstanding. /Johan Holmberg