Hello, keepers of Perl Wisdom.

I have the following file I'm trying to read in and then use for configuration info:

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
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.

Soko


In reply to 2 dimensional array sorting... by Soko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.