Olé Thank you Adrian. Your golf is good.
my $count = 1; my @sorted = map { $ref->{ $_->[0] }->{position} = $count++; $ref->{ $_->[0] } } sort { $a->[1] <=> $b->[1] } map [ $_, $ref->{$_}->{position} ], keys %{ $ref }; I sometimes question the legibility of such code but as an exercise, it's good to know. That last expression is interesting, Let's see if I'm getting it. Modify the value of {position} in that hashref then return the hashref. The ';' allowing you to perform more than one operation in the map expression...I feel a penny dropping. Thanks, Dermot. On 13 August 2014 11:11, Adrian Lai <p...@loathe.me.uk> wrote: > On 13 August 2014 10:33, Dermot <paik...@gmail.com> wrote: > > > # map { $ref->{ $_->[0] }->{position} => $count++ } > > You probably want = $count++, rather than =>. > > You possibly want: > > map { $ref->{ $_->[0] }->{position} => $count++; $ref->{$_->[0]} } > > Adrian. >