in reply to thoughts on learning perl basics

If you want no duplicates, a hash comes to mind. And since you are creating a hash anyway, you might as well make the values useful:
my @unsorted = ("A","B","C",9,"B","B","AAA","D",4,"EE","BBB",55,"BBBB","CCC",55,"BBDB +","BBB","JJ","ZZZZZZ","A blue flamingo doesn't have spots"); my %tmp; $tmp{$_} = length $_ for @unsorted; my @sorted = { $tmp{$a} <=> $tmp{$b} or $a cmp $b } keys %tmp;

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: RE: thoughts on learning perl basics
by Zaxo (Archbishop) on Jun 16, 2001 at 13:12 UTC

    Do you mean:

    -my @sorted = { $tmp{$a} <=> $tmp{$b} or $a cmp $b } keys %tmp; +my @sorted = sort { $tmp{$a} <=> $tmp{$b} or $a cmp $b } keys %tmp;

    After Compline,
    Zaxo