evolution & bioinformatics

Wednesday, October 22, 2014

sort hash by value and return the associated key

If instead you want to sort by numeric hash values, you'd write:
foreach my $key  (sort { $hash{$a} <=> $hash{$b} } keys %hashes)  {  do something; }
Posted by Li's blogger at 7:25 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2022 (1)
    • ►  October (1)
  • ►  2017 (1)
    • ►  June (1)
  • ►  2016 (1)
    • ►  December (1)
  • ►  2015 (7)
    • ►  August (1)
    • ►  July (2)
    • ►  May (2)
    • ►  March (2)
  • ▼  2014 (5)
    • ▼  October (3)
      • count redundant values in a array
      • Unique values in an array in Perl
      • sort hash by value and return the associated key
    • ►  April (1)
    • ►  January (1)
  • ►  2013 (20)
    • ►  November (2)
    • ►  July (1)
    • ►  June (2)
    • ►  May (5)
    • ►  April (4)
    • ►  March (4)
    • ►  February (2)
  • ►  2012 (17)
    • ►  December (10)
    • ►  November (7)

About Me

Li's blogger
View my complete profile
Awesome Inc. theme. Theme images by molotovcoketail. Powered by Blogger.