in reply to Re^2: Sort array using a ranking system from separate hash
in thread Sort array using a ranking system from separate hash

I'm pretty sure that my code will do what you want -- order a small array by the ordering contained in a hash.

My misunderstanding was that I thought you meant you had many arrays in a single run, rather than one array per run.

However, the basic process of sorting an array according to a frequency hash remains the same:

my %freq = ...; my @array = qw[ data items here ]; my @ordered = sort{ $freq{ $b } <=> $freq{ $a } } @array; ## for highe +st frequency first.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Sort array using a ranking system from separate hash
by Sandy_Bio_Perl (Beadle) on Aug 08, 2016 at 12:01 UTC

    Thanks, works brilliantly

        I don't think he ever read sort ...

        But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Re^4: Sort array using a ranking system from separate hash
by Sandy_Bio_Perl (Beadle) on Aug 08, 2016 at 10:51 UTC

    Thank you