• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

sorting hash

I have a hash like this:

%links=("firsturl"=>3,"secondurl"=>1,"thirdurl"=>2);

I have to sort it by value.

%links=("secondurl"=>1,"thirdurl"=>2,"firsturl"=>3);

Then I have to print the keys.
0
superquestions
Asked:
superquestions
  • 2
1 Solution
 
christopher sagayamCommented:
foreach $key(sort {$allurls{$a} <=> $allurls{$b}} keys %links)
{

}
0
 
christopher sagayamCommented:
oops it should be

foreach $key(sort {$links{$a} <=> $links{$b}} keys %links)
{

}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now