> That code seems redundant, because you're doing a seperate sort on the > fractions when you could instead use just one sort. Consider the > following functionally equivalent (and a lot more efficient) perl: > > @filelist = > sort { $a <=> $b } > grep {/^\d+(?:\.\d+)?$/} > readdir(INDIR); Except for two things: (1) the results are different: $ perl -e '@a=(1,2,"2.1","2.10", "2.2", 3); @a = sort { $a <=> $b } @a; print join(", ", @a)."\n";' 1, 2, 2.1, 2.10, 2.2, 3 whereas the other sort will produce: 1, 2, 2.1, 2.2, 2.10, 3 on the same input. It's not a numeric sort even though the strings look like fractions (think of them as document section numbers, which is quite similar to what they represented in the problem domain). (2) I asked the question primarily to find out how to convert sort { foo($a) <=> foo($b) || bar($a) <=> bar($b) || ... } into a Ruby idiom. Were that example reducible to a simple sort there would still be plenty of similar cases which won't be. Thanks to Pit's suggestion I converted the original perl expression to the Ruby equivalent: indir.entries.grep(/^\d+(?:\.\d+)?$/).collect{ |x| x += '.0' unless x =~ /\./ x }.sort{ |a,b| (a.to_i <=> b.to_i).nonzero? || (a.sub(/^.*\./, '').to_i <=> b.sub(/^.*\./,'').to_i) }.collect{|x| x.sub(/\.0$/, '') x } Rick -- http://www.rickbradley.com MUPRN: 10 (90F/97F) | compare the data random email haiku | from the real-time output and | data from these files.