in reply to Sorting geometric coordinates based on priority

Here is an OO-way (perhaps more readable):
#!/usr/bin/perl use strict; use warnings; #===================================================================== +===== {package point; sub new {return bless {x=>$_[1], y=>$_[2]}, __PACKAGE__;} sub Print { my ($self) = @_; return "(" . $self->{x} . "," . $self->{y} . ")"; } 1; } #===================================================================== +===== {package rect; sub new { # Takes 2 'point's return bless {p1=>$_[1], p2=>$_[2]}, __PACKAGE__; } 1; } #===================================================================== +===== my @rect_x = (3,2,4,0,3,0,4,0,3,2,0,4); my @rect_y = (0,0,0,1,1,0,3,3,3,3,2,2); my @rectangles; # Create the 'rect' objects, and collect in @rectangles for my $idx(0..$#rect_x){ push @rectangles, rect::->new(point::->new($rect_x[$idx], $rect_y[$i +dx]), undef); } @rectangles = sort { $b->{p1}{x} <=> $a->{p1}{x} || $a->{p1}{y} <=> $b->{p1}{y} } @rectangles; for (0..$#rectangles){ my $r = $rectangles[$_]; print "Rectangle ", ($_+1) , " -> ", $r->{p1}->Print(), "\n"; }

        ...it is unhealthy to remain near things that are in the process of blowing up.     man page for WARP, by Larry Wall