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?

One of the "features" of the Schwartzian transform is that you don't have to create any named temporary variables. So instead of using %saw or $prev you could do

my $data = [ { num => 'OF1234', title => 'title OF1234', }, { num => 'AF1234', title => 'title AF1234', }, { num => 'AF1234', title => 'title AF1234', }, ]; my @sorted = sort { $a->{num} cmp $b->{ num } } values %{ +{ map { ($_->{num},$_) } @$data }}; print join ', ', map { $_->{num} } @sorted;