in reply to Understanding how sort uniq works

Like I said yesterday, if you don't care about the order in which the values were added (if you are going to sort the output anyway, for example), you can store the $version as hash keys, rather than an array. (This is the rough equivalent of Python's sets, like what you showed us in the CB yesterday). Your structure can by using this statement instead of the push:

$hash->{$value}{$version}++; # The names you used yesterday
. And then you can iterate over it with:
for my $outer (keys %$hash) { my $subhash = $hash->{$outer}; for my $inner (sort { $a <=> $b } keys %$subhash) { # iterating over the sorted values } }
The values are stored unsorted, but you can just sort them at the last moment when going through them. You can use Data::Dump (or Data::Peek as pointed by Tux :) ). To see what the content of the $hash looks like.

Edit: try to avoid one-letter names, but never use $a outside of sort, as it has a special meaning for that case and some others (like some functions of List::Util)