http://qs321.pair.com?node_id=374737


in reply to Sorting - lower to upper

@keys = ((sort grep(/^[a-z]/, keys %hash)), (sort grep(/^[A-Z]/, keys +%hash)));

We're not really tightening our belts, it just feels that way because we're getting fatter.

Replies are listed 'Best First'.
•Re^2: Sorting - lower to upper
by merlyn (Sage) on Jul 15, 2004 at 19:14 UTC
    That'll make duplicate copies of everything that doesn't begin with a letter. Maybe you want to narrow those regexen down a bit.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.


    update: Oops, confused [^a-z] with ^[a-z]. So yes, everything without a letter will be absent, not duplicated. Doesn't change that there's something wrong with this solution.
      Seems to me that it should leave out anything that doesn't begin with a letter. Given the specs, that may or may not be desirable.

      We're not really tightening our belts, it just feels that way because we're getting fatter.
      It seems to me that rather than duplicate all non-first-lettered-words (nice hyphenate don't you think?), it actually discards all these words. I mean, the first list sorts all words which start with a small-case and the second list sorts all the first-upper-cased-words.

      I would appreciate explanation.

      Update: It seems that my pertinent and correct remark was voted down at least two times. I wonder what that means.
        It seems that my pertinent and correct remark was voted down at least two times. I wonder what that means.
        It doesn't necessarily mean anything, apart from the fact that there are some jackasses around. Downvotes are the most contentious and least useful feature of PerlMonks.

        We're not really tightening our belts, it just feels that way because we're getting fatter.