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

Thank you BrowserUK. I suspect I have rather poorly explained my problem. I have tried to clarify with my response to Rolf elsewhere in this node

  • Comment on Re^2: Sort array using a ranking system from separate hash

Replies are listed 'Best First'.
Re^3: Sort array using a ranking system from separate hash
by BrowserUk (Patriarch) on Aug 08, 2016 at 10:47 UTC

    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.

      Thanks, works brilliantly

      Thank you