my @sortedKeys = sort( keys %kernel ); foreach $w1 ( @sortedKeys ){ $totalsim = $maxsim = 0; @topX = (); $at2 = 0; foreach $w2 ( @sortedKeys ) {