in reply to Can Schwartzian transform be modified to sort an arrayref uniquely?
my %by; @by{ map $_->{num}, @$data } = 0 .. $#$data; @sorted_unique = @{$data}[ @by{ sort keys %by } ];
which actually begins to look reasonable.  On the other hand, the sure enough do-it-all-in-one-line with an anonymous hash:my %by = map{ $_->{num} => $_ } @$data; @sorted_unique = @by{sort keys %by};
goes through the array twice and also builds a hash.  And it even sorts the whole array before selecting unique elements which is the worst way to do it as khkramer demonstrates above.  It is kinda neat though.@sorted_unique = @{{ map{ $_->{num} => $_ } @$d }}{ sort map $_->{num}, @$d };
|
|---|