david2008 has asked for the wisdom of the Perl Monks concerning the following question:
gives as outputuse strict; use List::MoreUtils qw/uniq/; use Data::Dumper; my @x = (3,2); my @y = (4,3); print "unique results \n"; print Dumper([uniq(@x,@y)]); print "sorted unique results\n"; print Dumper([sort uniq(@x,@y)]);
unique results $VAR1 = [ 3, 2, 4 ]; sorted unique results $VAR1 = [ 2, 3, 3, 4 ];
Unfortunately the uniq does not work anymore.
There is an answer from amon that perl uses the sort function form where the first parameter is a function and the second a list, but i still don't understand why it does not execute uniq beforehand and then uses the sort LIST,instead of preferring the sort SUBNAME LIST form.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why does sort with uniq not work together
by tobyink (Canon) on Nov 27, 2013 at 12:51 UTC | |
|
Re: why does sort with uniq not work together
by 2teez (Vicar) on Nov 27, 2013 at 12:58 UTC | |
by hdb (Monsignor) on Nov 27, 2013 at 13:09 UTC | |
by 2teez (Vicar) on Nov 27, 2013 at 13:23 UTC | |
by hdb (Monsignor) on Nov 27, 2013 at 13:37 UTC | |
by 2teez (Vicar) on Nov 27, 2013 at 13:45 UTC | |
|
Re: why does sort with uniq not work together
by choroba (Cardinal) on Nov 27, 2013 at 13:13 UTC | |
by Anonymous Monk on Nov 27, 2013 at 22:34 UTC |