in reply to 2 dimensional array sorting...

Personally, I would think of this as an Item Catalog or Item Categories. Category 1 has a few items in it, Category 2 also. With this one-to-many relationship in mind, you could create a hash of arrays.
use strict; my %HoA; $HoA{0} = [ qw( corkscrews openers toppers ) ]; $HoA{1} = [ qw( glassware stemware tableware ) ]; # From there, sorting the keys is easy, the values is more complex. foreach my $category (sort keys %HoA) { print "Category $category contains:\n"; foreach my $houseware (sort {$a cmp $b} @{ HoA{$category} } ) { print ">>$houseware\n"; } }

Replies are listed 'Best First'.
Re: Re: 2 dimensional array sorting...
by aquarium (Curate) on Mar 27, 2003 at 09:56 UTC
    ...this isn't necessarily one-to-many, could be many-to-many..as it is a typical line-item table, ie it's a composite primary key made up of 2 foreign keys. If this database uses or will use any other tables besides this one, then I'd recommend to switch to using a database system now. This will simplify and standardize all your data handling (through SQL,) and keeps the database consistant according to relational rules...so you don't end up with widowed records etc. Chris