Re: sort an array unique.
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Jan 2007 08:21:28 -0800
On Jan 31, 10:43 am, Robert 'phaylon' Sedlacek <r...@xxxxxx> wrote:
Paul Lalli wrote:
On Jan 31, 9:23 am, "rajendra" <rajendra.pra...@xxxxxxxxxxxx> wrote:
Is there any command to sort an array uniquelly,something similar to
"sort -u" in unix.
Not built-in, but it's fairly easy to implement:
JFYI, it's also in List::MoreUtils as 'uniq'.
http://search.cpan.org/dist/List-MoreUtils/lib/List/MoreUtils.pm
Huh, so it is. For some reason, I'd forgotten about that. So my
short example gets even further reduced to:
$ perl -MList::MoreUtils=uniq -le'
my @unsorted_with_dups = qw/d a e c b e d a c b e a b c e d/;
my @sorted_uniques = sort(uniq(@unsorted_with_dups));
print "@sorted_uniques\n";
'
a b c d e
Thanks for the reminder,
Paul Lalli
.
- Follow-Ups:
- Re: sort an array unique.
- From: Robert 'phaylon' Sedlacek
- Re: sort an array unique.
- References:
- sort an array unique.
- From: rajendra
- Re: sort an array unique.
- From: Paul Lalli
- Re: sort an array unique.
- From: Robert 'phaylon' Sedlacek
- sort an array unique.
- Prev by Date: Module for Sending Keystrokes
- Next by Date: Re: sort an array unique.
- Previous by thread: Re: sort an array unique.
- Next by thread: Re: sort an array unique.
- Index(es):
Relevant Pages
|