in reply to Understanding how sort uniq works

I assume that you want the first example to produce the same result as the second. You can do this by storing the result of the sort the same way.
use strict; use warnings; use List::Util qw(uniq); use Data::Dumper; my $line = 'k,g,a,v,f,c'; my $href = { v => ['foo'], }; my ($k,$g,$a,$v,$f,$c) = split(/,/,$line); push(@{$href->{v}},$a); @{$href->{v}} = sort(uniq(@{$href->{v}})); # Compare to your Case II print Dumper($href);
Bill