On Mon, May 31, 2004 at 12:42:50PM +1000, Ashley Maher wrote: > In a 1D array I'd order using sort. This is 2D. My brain wave was as > this was a 2D array write a routine to work through the 2D and insert > the new data in the correct position and return.
Still use sort e.g. #!/usr/bin/perl -wT use strict; use Data::Dumper qw(Dumper); my @original = ( [ "3", "test1" ], [ "2", "test2" ], [ "7", "test3" ], [ "9", "test4" ], ); my @new = qw(6 testing); # Add to original push @original, [EMAIL PROTECTED]; # Sort my @sorted = sort { $a->[0] <=> $b->[0] } @original; print Dumper [EMAIL PROTECTED]; Cheers, Gavin -- Open Fusion P/L - Open Source Business Solutions [ Linux - Perl - Apache ] ph: 02 9875 5032 fax: 02 9875 4317 web: http://www.openfusion.com.au mob: 0403 171712 - Fashion is a variable, but style is a constant - Programming Perl -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
