Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm trying to do something a bit more complex now:

my @sorted_phrases = sort { $b->{sort_number} <=> $a->{sort_number +}, $b->{count} <=> $a->{count} } values %$strings;

..instead of just:

my @sorted_phrases = sort { $b->{count} <=> $a->{count} } values %$strings;

Basically, what I need to do - is :

1) Sort by the value "count" as they were done before
2) If the 2nd array element has a value of "0" for "count", then it will order them by sort_number thereafter.

I've tried all kinda things - including this messy bit of code - but I can't seem to get it working :(

my @sorted_phrases_2; # my $i = 0; foreach (my $i = 0; $i <= $#sorted_phrases; $i++) { local $_ = $sorted_phrases[$i]; if ($i == 1) { print "BLA BLA XXX - \"$_->{count}\" " . Dumper($_); if ($_->{count} < 1) { my $chosen_id_now = $sorted_phrases[0]->{sort_number} ++ 1; print qq|<br />Current sort was: $sorted_phrases[0]->{ +sort_number} , and new one is $chosen_id_now <br />|; foreach my $tmp (@sorted_phrases) { if ($tmp->{sort_number} == $chosen_id_now) { push @sorted_phrases_2, $tmp; } } } } else { push @sorted_phrases_2, $_; } } @sorted_phrases = @sorted_phrases_2;

Thanks for any ideas - as I'm stumped :(



In reply to Re^2: Trying to make a string generated like google by ultranerds
in thread Trying to make a string generated like google by ultranerds

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Discipulus]: problematic? i came back after just a week of course, I forgo teverything..

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2017-12-18 11:22 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (483 votes). Check out past polls.