ara.t.howard / noaa.gov wrote: > that sorts strings like this > > /dmsp/nrt/data/incoming/afwa/2006.f13_0731556_DT.DAT > /dmsp/nrt/data/incoming/afwa/2006.f13_0731737_DS.DAT > > where > > 2006.f13_0731556_DT.DAT > ^^^^ ^^^ ^^^^^^^ ^^ > | | | | > year sat time type > > first by sat, then by year, then by time and finally by type > > using only > > pats = %w[ f\d\d ^\d{4} _\d{7} _\w{2} ].map{|p|/#{p}/} > > basenames.sort!{|a,b| pats.map{|pat| a[pat]} <=> pats.map{|pat| b[pat]} } Interesting idea, but may be _\w{2}\. would be more appropriate instead of _\w{2} which can match also against a beginnig of the 'time' part. :) P.