I'm not entirely positive I understand what you need here. You want the number sorted based on how close they are to... one another, or a central point on the grid? If you want to draw a line connecting them, it sounds like you need to start at one side, and go directly across the plane (left to right for simplicity sake). If that is the case you would want the list sorted based on the X cooridante in each pair. Beacuse these are pairs of numbers, it sounds like you should have an array of arrays (two dimensional array). To sort a two dimensional array based of the first of the two elements in the inner arrays:

my(@sorted_array) = sort({$a->[0] <=> $b->[0]} @unsorted_array);

See sort for details on using sort. See perlre for details on nested data structures.

May the Force be with you

In reply to Re^3: Declaring variables recursively by JediWizard
in thread Declaring variables recursively by sciarnold

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.