2007/7/26, Marcin Tyman <m.tyman / interia.pl>:
> Hi,
>
> Does anybody know how to list directory in alphabetical order? i.e.
> I have following files:
> a10
> a1
> a2
> a20
>
> sort method sorts them as follows:
>
> a1
> a10
> a2
> a20
>
> but I need such order:
>
> a1
> a2
> a10
> a20

Apparently you want to _sort by_ the numeric part.  You can extract it
with a regular expression like this:

irb(main):017:0> a.sort_by {|x| x[/\d+/].to_i }
=> ["a1", "a2", "a10", "a20"]

Kind regards

robert