On Wed, 15 Mar 2006, Mike Stok wrote:

> Tangentially speaking you can use unpack and sort_by to do this kind of thing 
> if it suits the situation (admittedly there's not a sort_by!, but let's not 
> let that get in the way :-)
>
> sorted_basenames = basenames.sort_by { |name|
>  name.unpack('A4 x A3 x A7 x A2').values_at(1, 0, 2, 3)
> }
>
> or the delightful
>
> sorted_basenames = basenames.sort_by { |name| name.unpack('x5 A3 X8 A4 x5 A7 
> x A2') }
>
> This is just an excuse to expose unpack and sort_by to people, not a 
> suggestion that it's necessarily appropriate or better in this case.

i actually like that.  whether regexes or pack codes are more obtuse is
definitely debatable - but that's pretty clean looking

thanks for the tip.

-a
-- 
share your knowledge.  it's a way to achieve immortality.
- h.h. the 14th dali lama