I'm not exactly sure what you're trying to do here, but I think you might
want to use a standard technique for sorting on multiple fields:
sort {$a cmp $b or $hash{$a} cmp $hash{$b}} keys %hash;
This first compares $a vs. $b. If they're equal, then it falls back to comparing $hash{$a} against $hash{$b}.
Your code is using an && instead of || or "or". I don't understand what that's for.
However, in the example I just gave, the secondary comparison is useless, because a hash always has unique keys. Therefore, the second part of the "or" clause will never be evaluated.
I'm not sure why you're comparing $my_server_hash{$a} vs $my_server_hash{$b}, because these are apparently hash refs, which don't compare in any useful way.
If you give more info on the format of the data in your hash (as opposed to what it looks like once you render it in html) we might be able to give you more useful help.
Alan
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.