Soko has asked for the wisdom of the Perl Monks concerning the following question:
I have the following file I'm trying to read in and then use for configuration info:
These elements need to be kept together, as they are ProductTypeNumber and ProductTypeName. As you can see, keeping this info in a hash won't work, since I'd have duplicate keys. An array of arrays would seem better. This isn't much of a problem, except for the fact that the user might be able to edit the text file and screw up the ordering. I'd like to be able to read this all in and sort the data by element 1, then element 2. Being a relative n00b to Perl, I'm not sure how to apply array refernces and/or the <=> method in sort to get the data straight. Google tuned up nil, as did looking through the code snippets (well, nothing seemed to fit my problem very well). Any suggestions would be greatly appreciated.0,corkscrews 0,openers 0,toppers 1,glassware 1,stemware 1,tableware 2,bags 2,baskets, 2,boxes 3,books 3,magazines 3,postcards 3,clothing 4,canles 4,candlesticks 5,artwork
Soko
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2 dimensional array sorting...
by Zaxo (Archbishop) on Mar 27, 2003 at 08:22 UTC | |
by Soko (Sexton) on Mar 27, 2003 at 19:18 UTC | |
|
Re: 2 dimensional array sorting...
by Cody Pendant (Prior) on Mar 27, 2003 at 08:27 UTC | |
|
Re: 2 dimensional array sorting...
by Lhamo Latso (Scribe) on Mar 27, 2003 at 09:09 UTC | |
by aquarium (Curate) on Mar 27, 2003 at 09:56 UTC | |
|
Re: 2 dimensional array sorting... (no sort)
by tye (Sage) on Mar 27, 2003 at 16:16 UTC | |
|
Re: 2 dimensional array sorting...
by Anonymous Monk on Mar 27, 2003 at 10:30 UTC | |
|
Re: 2 dimensional array sorting...
by jonadab (Parson) on Mar 27, 2003 at 14:13 UTC | |
|
Re: 2 dimensional array sorting...
by zenn (Sexton) on Mar 27, 2003 at 13:13 UTC | |
|
Re: 2 dimensional array sorting...
by leriksen (Curate) on Mar 28, 2003 at 02:16 UTC | |
|
Re: 2 dimensional array sorting...
by Anonymous Monk on Mar 29, 2003 at 00:53 UTC | |
by BrowserUk (Patriarch) on Mar 29, 2003 at 02:08 UTC |