I have a moderately complicated data structure I want to sort according to somewhat esoteric rules. This seems to be exactly what Data::Sorting was designed for. I am having trouble figuring out how to apply the module tp my specific problem, though. I have read the docs on CPAN several times, but I always end up mildly confused about exactly what to do.

The subroutine that needs the sorted data is passed a reference to a hash. The keys of the hash are arbitrary numbers, and the values are arrays that hold information about a particular person. More precisely, the hash has this structure:

{number_1 => [last_name1, first_name1, middle_name1, other_stuff1], number_2 => [last_name2, first_name2, middle_name2, other_stuff2], . . . number_N => [last_nameN, first_nameN, middle_nameN, other_stuffN], }

I want to sort the keys (number_1 ... number_N) by the alphabetical ranking of the name in that key's value. As usual, the priority is last_name > first_name > middle_name. Nothingness should sort before everything else, and hyphens should sort before "A".

Since the previous paragraph ended up more confusing than I'd hoped, I have an example. Suppose I want to sort the keys of this hash:

(spaces added for clarity) {1 => [Frog, Fuzzy, A, other_stuff], 2 => [Frog, Fuzzy, , other_stuff], 3 => [Toad, Zola, Q, other_stuff], 4 => [Frogger, Anthony, J, other_stuff], 5 => [Frog-Toad, Berl, G, other_stuff]}

The keys should end up in the order (2, 1, 5, 4, 3)

I would really like to get this working within a week or so. Any help would be greatly appreciated.

___________
-- Fuzzy Frog

P.S. I do not mean to imply that simonm's docs are in any way deficient. I'm sure the problem lies entirely with me.

-- FF

In reply to Data::Sorting by Fuzzy Frog

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.