Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem in nested sorts

Thread Tools

Problem in nested sorts

Posts: n/a
On 25 Mar 2006 20:54:48 -0800, "David McNerney" <(E-Mail Removed)> wrote:

>I duplicate your finding ... if those two print statements are
>commented out, both the nested sorts work correctly. So, it certainly
>does seem that the sort operator cannot always be relied upon when used
>with anonymous functions that contain anything but simple comparison.
>That's really fine, as far as I'm concerned, now that I know ... I can
>always declare a prototyped sort function in the future if I'm writing
>code that I expect to get called from within a sort. I don't, however,
>find any warnings about such code in the "sort" function documentation
>in the Camel book, my primary reference.
>There are any number of reasons why one might want to have what you
>refer to as "extra" code in a sort. This comes up when sorting objects.
>We have a large class library at our site, and one of the chief reasons
>that we use Perl, and not some other language like Java, C, or Visual
>Basic, is because it allows us to program at a high conceptual level,
>throwing around lists of objects with sort, grep and map. If you are
>sorting a list of objects, you might have code like this:
>my @sortedList = sort { $a->method() <=> $b->method() } @list;

A list of instantiated objects from which your calling method() to compare
encapsulated data? Cool... Just remember {} is a block, not an anonymous

In 'C', you can write structures (records or classes)
with common methods that know and act on common data, to be returned
to a pool collector, as in a sort or a find.

You should consider that any sort that can be done in method()
is absolutely misplaced when done in a general collecting scheme,
as you describe.

Has nothing to do with Perl sort. This is just common knowledge.
There is no example in 'C' you can give me that would justify this at all.

Sorry dude, the find is good, the premise is wrong.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hardware question of sorts lugnut DVD Video 0 01-20-2007 05:27 PM
Alphabetical sorts Ron Adam Python 7 10-17-2006 04:21 PM
XML parser that sorts elements? Python 6 09-28-2006 03:33 PM
Is there anyway to change the default way NTFS "sorts" files ny name? Jimmy Dean Computer Support 3 09-03-2004 05:18 AM
control-c and threads, signals in 2.3 causing all sorts of issues Srikanth Mandava Python 1 02-19-2004 12:41 PM