PDA

View Full Version : hash building issues


bazz
05-11-2006, 01:58 PM
Hello.

Solved this by building an array instead even though it was an exercise in learning hashes. :eek:

I am running a loop and using the results to compile a hash.


$rounded = 1.76 or 6.3 (for example)

%nearby;
$nearby{$rounded}{$nearbyBusinessName}{$NorthSouth}{$WestEast} = $_;



I want to output the data in order of smallest $rounded rather than, presently, where it is outputted alphabetically by $nearbyBusinessName.

Struggling again.

Bazz

KevinADC
05-11-2006, 07:41 PM
use the sort function and the numeric comparison operator:

foreach my $keys (sort {$a <=> $b} keys %nearby) {
print "$keys\n";
}

bazz
05-16-2006, 03:42 PM
Thank you Kevin. I got it working :thumbsup:

bazz