--- Jeff Pinyan <[EMAIL PROTECTED]> wrote:
> >>  @new = sort {
> >>               my($A) = $a =~ /\@([^:]+)/;
> >>               my($B) = $b =~ /\@([^:]+)/;
> >>               return  $A cmp $B;
> >>       } @ary;
> That sorting method does a lot of work -- that is, it does things
> more than once.  I suggest you use a schwarztian transform, or the
> Orcish manuever, to increase speed.
>   @new =
>     map  { $_->[0] }
>     sort { $a->[1] cmp $b->[1] }
>     map  { [ $_, /\@([^:]+)/ ] }
>     @orig;

I thought about that on the way home. 
Was gonna suggest it this morning. =o)

>   {
>     my %cache;
>     @new = sort {
>       ($cache{$a}) = $a =~ /\@([^:]+)/ if not exists $cache{$a};
>       ($cache{$b}) = $b =~ /\@([^:]+)/ if not exists $cache{$b};
>       $cache{$a} cmp $cache{$b}
>   } @orig;

While this is reasonably obvious, I'd never heard it called that.
A name always helps me remember things like that. Thanks.
> You can read about these two at:
>   http://www.pobox.com/~japhy/docs/sorting.html

By the way, for any of you who may not know --
the [OT] in the header is a fairly standard flag for list people.
It means "Off Topic" -- a post that adds nothing pithy to the thread.
OT posts are acceptable so long as they don't bog down the list, though
if you do it very often people will start ignoring everything you send,
and eventually someone will get rude. 

Putting [OT] in the subject header is just a courtesy to those who
aren't interested in reading unrelated material. It warns them that
they can skip this one. Similarly, one commonly leaves the rest of the
subject line minimally edited so that those who are following that
thread can choose whether ot not to read that entry.

Also, (and this one is actually important....)
When posting a message, BE DESCRIPTIVE! >:o]

Don't just say "help" or EVER leave it blank. Remember that you are
either asking for help, or trying to help someone. In either case, make
sure that you put a concise description of the question in the subject.
For example, this message started with the subject line "Sorting".
That's not horribly specific, but lets anyone know that it's a sort
related question. In this case, one word was probably enough, though
usually you want a short phrase or sentence.

And finally, please don't think this tirade was because I thought
someone needed a scolding! lol! I just started an OT comment, and then
remembered to mark it.... and drifted from there. Sorry for the blather
-- but I hope someone got something useful from it.

Have a *great* day, all!


print "Just another Perl Hacker\n"; # edited for readability =o)
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

Reply via email to