I have written this same sort of formula before and it is actually pretty easy as long as you avoid the working with the A vs B vs C headache.

sub _team_standings { $b->get_wins_total <=> $a->get_wins_total or $b->get_wins_division <=> $a->get_wins_division or $b->get_wins_home <=> $a->get_wins_home or $b->get_run_difference <=> $a->get_run_difference or $b->get_runs_scored <=> $a->get_runs_scored or $a->get_reg_schedule_id <=> $b->get_reg_schedule_id }

If you notice, I am sorting my teams all based upon some team stat except the last one. There I am using a schedule id as my tie breaker instead of a head-to-head comparison.

The problem with the head-to-head comparison is when you have 3 or more teams tied together and you are trying to determine who would be ahead, it creates a catch-22 scenario. Example:

A beat B B beat C C beat A

If you are trying to use head-to-head comparison, there is no way to resolve it. You are basically down to using a coin flip or some other stat to resolve the issue.

For the sake of simplicity, I would ignore using head-to-head comparisons and look at other values instead.


In reply to Re: Adding Special Rules to Sort by Herkum
in thread Adding Special Rules to Sort by ctfishman

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.