Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Sorting based on existence of keys
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="sln, post: 4863153"] You keep saying 'Pre-Filter' as if it actually means anything in relation to sort. This is a particular case of sort implentation that has specific logic. There are no multiple sort keys/fields, whatever in this case. The logic still has to be adhered to in as far as this boolean: $h{$a} and $h{$b} exist ===> length($h{$a}) <=> length($h{$a}) $h{$a} exists but $h{$b} doesn't ===> -1 $h{$a} does't exist but $h{$b} does ===> 1 Neither $h{$a} nor $h{$b} exists ===> 0 (I didn't check it, but it looks right.) It doesen't matter if you do it as a pre-filter or all at once. It may look cleaner as a pre-filter, but that don't count for squat as far as speed. The same number of operations have to be performed no matter where the logic is. As far as multi-key/fields sorting, doing it in one pass, regardless of the sort method always is faster. Less runs through the function or block. -sln [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Sorting based on existence of keys
Top