my @also = sort {$a->[0] <=> $b->[0]} @points; for my $i (reverse 0 .. $#points) { splice @also, $i, 1 if $points[$i] ne $also[$i]; }