bob=>13
brian=>14
jeff=>13
####
brian=>14
bob=>13
jeff=>13
####
#copys the hash array into a pair of arrays.
my @sortedkeys = sort(keys %queryterms);
my $key;
my @array1;
my @array2;
foreach $key (@sortedkeys)
{
push(@array1,$key);
push(@array2,$queryterms{$key});
}
## sort area. sorts the two arrays keeping each pair value together across the split.
my $index=0;
my $smallest=0;
my $count=@array1;
my $x;
for ($x=($count-1);$x>0;$x--){
$smallest=$x;
#Find the smallest element with this
for ($index=0;$index<=$x;$index++)
{
next if ($array2[$smallest] < $array2[$index]);
next if (($array2[$smallest] == $array2[$index]) && (uc($array1[$smallest]) gt uc($array1[$index])));
$smallest=$index;
}
#swap the smallest and the top element
if ($x != $smallest){
($array1[$smallest],$array1[$x])=($array1[$x],$array1[$smallest]);
($array2[$smallest],$array2[$x])=($array2[$x],$array2[$smallest]);
}
}