You've been pointed to documentation which you appear not to have read. You been asked for information which you haven't supplied. Without doing these things, I don't know how you think we can help you.

I provided a link to sort. Here you'll find many examples including this basic one for sorting numerical data in descending order:

# sort numerically descending @articles = sort {$b <=> $a} @files;

Corion provided a link to DBI (in Re^3: Ranking MySQL Entries?). If you're unfamiliar with that module, look the "Simple Examples" section in that documentation.

Once you have your data, in whatever data structure you choose, you'll probably need a more complicated sort than the basic example shown above. Perhaps something like this:

#!/usr/bin/env perl -l use strict; use warnings; use Data::Dump; my @unordered = ( { id => 12, rownum => 1, rank => 27 }, { id => 31, rownum => 3, rank => 72 }, { id => 45, rownum => 5, rank => 54 }, ); my @ordered = sort { $b->{rank} <=> $a->{rank} } @unordered; print 'Unordered:'; dd \@unordered; print 'Ordered:'; dd \@ordered;

Output:

Unordered: [ { id => 12, rank => 27, rownum => 1 }, { id => 31, rank => 72, rownum => 3 }, { id => 45, rank => 54, rownum => 5 }, ] Ordered: [ { id => 31, rank => 72, rownum => 3 }, { id => 45, rank => 54, rownum => 5 }, { id => 12, rank => 27, rownum => 1 }, ]

You need to follow the guidelines in "How do I post a question effectively?". Note what it says about posting code, data, output and warning/error messages. Pay particular attention to what it says about providing "a minimal script that reproduces your problem" in your post. Unless you do this, we can not help you further!

-- Ken


In reply to Re^3: Ranking MySQL Entries? by kcott
in thread Ranking MySQL Entries? by jdlev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.