Ok, they say "never assume", but I'm gonna suggest a different answer than the others given so far, based on the following assumption: Aren't your arrays actually triplets of coordinates, each triplet ($x[$i], $y[$i], $z[$i]) representing a point in 3D?

If that is the case, might I suggest a change in data structures?
my @points; # This will add one point (the first one in your arrays # above) to another type of data structure. my %this_point = {x => 0, y => 0, z => 25}; push @points, \%this_point; # Do this for as many points as you have. You can # adapt the method you use to fill your three arrays # to create this kind of data structure using the # example above.
That would allow you to refer to the X component of a point $i as:
$points[$i]->{x}

Then, the sorting becomes a bit easier:
# Sort by z first, then sort by x for each point @points = sort { $a->{x} <=> $b->{x} } sort { $a->{z} <=> $b->{z} } @points;
(note: untested, but should give you the idea)

I find this data structure more intuitive, since the triplets of coordinates, which are related (they form a point in 3D), are actually together in the data structure, whereas in the arrays in your original post they are separated.

In reply to Re: Sorting issues by Skylark
in thread Sorting issues by hokie

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.