Hi monks, I have 4 arrays with coordinates that I am looking to sort. @rect_x, @rect_y correspond to the lower left corners of some rectangle. @point_x, @point_y are the x and y coordinates of some point associated with this rectangle (maybe inside or outside)
Eg: $rect_x[0], $rect_y[0] are the coordinates of rectangle 1. $point_x[0], $point_y[0] are some point linked to rectangle 1
Suppose I have the following coordinates:
@rect_x = {3,2,4,0,3,0,4,0,3,2,0,4} @rect_y = {0,0,0,1,1,0,3,3,3,3,2,2} How can I sort this to get Rectangle 1 -> (4,0) Rectangle 2 -> (4,2) Rectangle 3 -> (4,3) Rectangle 4 -> (3,0) Rectangle 5 -> (3,1) Rectangle 6 -> (3,3) Rectangle 7 -> (2,0) Rectangle 8 -> (2,3) . . . . Rectangle n-1 -> (0,2) Rectangle n -> (0,3)
Priority: (highest x coordinate, lowest y coordinate) I also need to have the the corresponding point coordinates for each sorted rectangle Thanks for the help!

In reply to Sorting geometric coordinates based on priority by Ppeoc

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.