# Sort by LONG (index 0=NUM, 1=SEC, 2=LONG, 3=LAT) my @sorted_recs = sort { $$records[$a][2] <=> $$records[$b][2] } @records;