Gossamer Forum
Home : General : Perl Programming :

Re: Case insensative sort

Quote Reply
Re: Case insensative sort In reply to
@files = sort { lc $a cmp lc $b } grep { /.tmp/ } readdir(DIR);

will do the first one, and for the second:

foreach $record (sort { lc $a cmp $b } keys %db_array) {

to sort case insensitive on the keys of the hash, or to sort on the values:

foreach $record (sort { lc $db_array{$a} cmp lc $db_array{$b}) {

The lc just makes the string lower case.

Hope that helps,

Alex
Subject Author Views Date
Thread Case insensative sort WPeterson 5382 Oct 26, 1998, 1:58 PM
Post Re: Case insensative sort
Alex 5211 Oct 26, 1998, 2:26 PM
Post Re: Case insensative sort
WPeterson 5252 Oct 26, 1998, 2:49 PM