in reply to 2 dimensional array sorting...

Better referred to as elements 0 and 1, you can sort as you want with the or operator. <=> is for numeric comparison, cmp for strings. If @data contains your AoA,

my @sorted_data = sort { $a->[0] <=> $b->[0] or $a->[1] cmp $b->[1] } @data;

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: 2 dimensional array sorting...
by Soko (Sexton) on Mar 27, 2003 at 19:18 UTC
    Thanks, Zaxo. That snippet did it for me.

    I'm using the number portion to do two things. First, it builds a longer product number. Second, there are actually several configuration files in a sort of tree structure. These files are keyed by the first number. If the user selects "toppers" from the list, then toppers is inserted into my BrowseEntry widget and the program goes on to read "style0.txt" in, which is another file of the same structure which contains various styles of toppers, corkscrews and openers. Using a 2d array seemed simpler.

    I might migrate this to my PostgreSQL database, but I wanted it easy for people to edit the product build info even on a Windows machine. If anyone is interested in the code snippets, I'll post the relevant parts. Thanks to all that replied!

    Soko