On Jul 28, 2004, at 12:27 PM, perl.org wrote:

I have a list of files I want to case-insensitive sort by extension, files
with no extension appearing first. It should handle both Windows and Unix
directory separators. I think I have working code, but I am interested in the
various syntax for this one - there MUST be a better way than my feeble attempt:

I'm never one to abuse working code, but if your definition of "better" has something to do with sorter, a simple Schwartzian Transformation seems to work:


@input = map { $_->[0] }
                 sort { lc($a->[1]) cmp lc($b->[1]) }
                 map { m/\.([^.]+)$/ ? [$_, $1] : [$_, ''] } @input;

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to