The interesting part is the sort block. It consists of two expressions, $g2o{$a} cmp $g2o{$b} and $a <=> $b.

The cmp operator returns three possible values, +1, 0 or -1, depending on whether the left side is greater, equal or smaller than the right side when compared as strings. The same holds true for the <=> ("spaceship") operator, except the comparison is done as numbers.

So putting this together, the sort block first compares $g2o{$a} to $g2o{$b} as strings, and if the two are equal as strings it compares $a and $b as numbers to determine which comes first.

Basically the sort block seems to sort first on the values of %g2o and then on the numerical value of @allgs.

PS: Plz right n full English wrds - it maeks it easier 4 us 2 hlp u. Txtspk might be OK for your mobile but not here.


In reply to Re: can someone plz decode this sort for me? by Corion
in thread can someone plz decode this sort for me? by rhxk

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.