in reply to Sorting geometric coordinates based on priority

G'day Ppeoc,

Here's my take on this:

#!/usr/bin/env perl use strict; use warnings; 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 @point_x = (0) x @rect_x; my @point_y = (0) x @rect_x; my @sorted = sort { $b->[0] <=> $a->[0] || $a->[1] <=> $b->[1] } map { [ $rect_x[$_], $rect_y[$_], $point_x[$_], $point_y[$_] ] } 0 .. $#rect_x; use Data::Dump; dd \@sorted;

Output:

[ [4, 0, 0, 0], [4, 2, 0, 0], [4, 3, 0, 0], [3, 0, 0, 0], [3, 1, 0, 0], [3, 3, 0, 0], [2, 0, 0, 0], [2, 3, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 2, 0, 0], [0, 3, 0, 0], ]

— Ken