You will probably be better off breaking the problem into two operations: first do the sort that you have now, but put the sorted keys into an array:
@first_sort = (sort { .... } keys %my_server_hash );
Once that's done, now partition the array into separate bins, which you can then use to print your whole set in whatever order you want. (Who knows, maybe next week you'll want the admins to be listed at the top instead of the bottom...) Pseudo-code example:
for (@first_sort) { if ( &goes_first( $my_server_hash{$_} )) { push( @topset, $_ ); } elsif ( &goes_second( $my_server_hash{$_} )) { push( @set2, $_ ); # more steps if you want... } else { push( @lastset, $_ ); } } # now go through those subset arrays and print them in turn; # alpha-sorting is preserved within each subset...
I'm sure obfuskaters would love to try cramming it all into a single monster sort block, but you might find it more maintainable if your priorities are stated explicitly.

In reply to Re: hash sort problems by graff
in thread hash sort problems by Conal

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.