[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: how to sort this array
From: "Robert Klemme" <shortcutter () googlemail ! com>
Date: 2008-10-31 8:13:32
Message-ID: 9e3fd2c80810310114p598f1447p93fb434801f55ab0 () mail ! gmail ! com
[Download RAW message or body]
And here's a variant for cases where there are multiple subdirectories:
irb(main):010:0> puts files.sort_by {|f| f.scan(/\d+/).map{|x|x.to_i}}
c:/ruby/self/2004/1.txt
c:/ruby/self/2004/2.txt
c:/ruby/self/2004/3.txt
c:/ruby/self/2004/10.txt
c:/ruby/self/2004/20.txt
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic