in reply to (Ovid) Re: Can Schwartzian transform be modified to sort an arrayref uniquely?
in thread Can Schwartzian transform be modified to sort an arrayref uniquely?
You can also either do the grep first so that the sort will be faster or leave it there and make use of the fact that the data is now sorted to avoid creating a possibly large %saw hash:
Which doesn't matter for such a small data set, of course. (: - tye (but my friends call me "Tye")my $prev= ""; my @sorted= grep { ( $_->{num} ne $prev, $prev= $_->{num} )[0] } sort { $a->{num} cmp $b->{num} } @$data;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Can Schwartzian transform be modified to sort an arrayref uniquely?
by khkramer (Scribe) on Jan 04, 2002 at 22:51 UTC |