From: Douglas Seifert Date: 2009-05-18T23:38:17+09:00 Subject: Re: Sorting numbers as strings --001e6837897789c05d046a30be24 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Maybe something like this: irb> a = ["FastEthernet0/1", "FastEthernet0/10", "FastEthernet0/11", "FastEthernet0/12", "FastEthernet0/13", "FastEthernet0/2", "FastEthernet0/3", "FastEthernet0/4", "FastEthernet0/5", "FastEthernet0/6", "FastEthernet0/7", "FastEthernet0/8", "FastEthernet0/9"] irb> a.sort_by{|s| n,i = s.split('/'); [n, i.to_i]} => ["FastEthernet0/1", "FastEthernet0/2", "FastEthernet0/3", "FastEthernet0/4", "FastEthernet0/5", "FastEthernet0/6", "FastEthernet0/7", "FastEthernet0/8", "FastEthernet0/9", "FastEthernet0/10", "FastEthernet0/11", "FastEthernet0/12", "FastEthernet0/13"] On Mon, May 18, 2009 at 7:27 AM, Jack Bauer wrote: > Jack Bauer wrote: > > First is how I wanted them sorted: > > > > Sorry I meant to say that the first version is how they're CURRENTLY > being sorted and the second version is how I WANT them sorted. > -- > Posted via http://www.ruby-forum.com/. > > --001e6837897789c05d046a30be24--