As you will see in your research, the built-in sort facility (as well as various CPAN modules) provide the means to supply your own “comparison function,” whose job is to determine the relative ordering of two records. This comparison function will of course be called thousands of times.

Having said that, I'd also point out that the sort commands of many operating systems (including Linux/Unix) provide many options ... so that you may well find that you have no need for “your own comparison function.” If the standard Unix sort command is told that:

  1. I want to sort by the second field...
  2. I want to do a numeric comparison...
  3. The field-separator is “a vertical bar” ...
... then it can probably do exactly what you want, no programming required.

Your research will quickly confirm that this is a very routine and straightforward requirement. It is well worth the time to acquaint yourself with the plethora of existing text-handling tools that are available.


In reply to Re: Sort by specific column by Anonymous Monk
in thread Sort by specific column by mraja_23

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.