in reply to beginner - ordering tuples

This example simplifies your external file to a DATA-section.

use strict; use warnings; my @datas; #- parse input for (<DATA>){ my @entries = m/<(\d+),(\d+)>/; push @datas, [@entries]; } #- sort @datas = sort { $a->[0] <=> $b->[0] } @datas; #- output use Data::Dumper; print Dumper \@datas; __DATA__ <12,20> <1,5> <7,10>

see perllol explanation of the datastructure (Array Of Arrays) and check how to apply the sort command.

Cheers Rolf

Replies are listed 'Best First'.
Re^2: beginner - ordering tuples
by Anonymous Monk on Nov 13, 2010 at 01:36 UTC
    thanks to you both. I can follow the second answer but would never have thought do it like that.