    my %hash = (a=>1, b=>3, c=>3, d=>2, e=>1, f=>1);
    my %hash_by_val;
    
    for my $key ( sort { $hash{ $a } <=> $hash{ $b } 
                       } keys %hash  
                ) { 
       push @{$hash_by_val{$hash{$key}}}, $key;
    }
    
    
    for my $key (sort keys %hash_by_val){
       my @arr        = @{$hash_by_val{$key}};
       my $arr_length = $#arr;

       for (0..$arr_length){
          my $randnum = int(rand($arr_length));
          my $val     = splice (@arr,$randnum,1);

          $arr_length--;
          print "$key : $val\n";                    # notice: output varies b/t runs
       }
    }