Another late one but never mind! I also adopted the extra data line. Then a pass through the data once to find who wrote "THIS BOOK FIRST" and the rest can be done in a Schwartzian transform.
#!/usr/local/bin/perl -w # use strict; our @thingsToSort = ( {author => 'bart', title => 'skateboarding'}, {author => 'lisa', title => 'postmodernism'}, {author => 'marge', title => 'hairstyles'}, {author => 'lisa', title => 'THIS BOOK FIRST'}, {author => 'homer', title => 'donuts'}, {author => 'bart', title => 'coolness'}, {author => 'lisa', title => 'eating veggies'}); our $firstAuthor = q(); foreach (@thingsToSort) { next unless $_->{title} eq 'THIS BOOK FIRST'; $firstAuthor = $_->{author}; last; } print map {"$_->[0]->{author}: $_->[0]->{title}\n"} sort { $b->[1] <=> $a->[1] || $b->[2] <=> $a->[2] || $a->[0]->{author} cmp $b->[0]->{author} || $a->[0]->{title} cmp $b->[0]->{title} } map { [ $_, $_->{title} eq 'THIS BOOK FIRST', $_->{author} eq $firstAuthor ] } @thingsToSort;
I tried to think of a way to accomplish the first pass in the transform to make things simpler but failed.

Cheers,

JohnGG


In reply to Re^2: Twisted sort requirements by johngg
in thread Twisted sort requirements by forrest

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.