in reply to noncase-sensitive sorting
my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, uc $_ ] } @unsorted;
The reason this method is often preferable is that the uc function is only called once per item being sorted, rather than each time that item is compared. Yes, there is some cost associated with the two map transforms, but that usually will be less than the cost of 'expensive' routines in the comparison function.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: noncase-sensitive sorting
by Roger (Parson) on Dec 02, 2003 at 07:07 UTC | |
by sauoq (Abbot) on Dec 02, 2003 at 11:08 UTC | |
by davido (Cardinal) on Dec 02, 2003 at 07:16 UTC | |
by Roger (Parson) on Dec 02, 2003 at 07:25 UTC | |
by Abigail-II (Bishop) on Dec 02, 2003 at 10:48 UTC | |
by Roger (Parson) on Dec 02, 2003 at 11:34 UTC | |
|