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="Uri Guttman, post: 4863089"] JE> $h{$a} and $h{$b} exist ===> length($h{$a}) <=> length($h{$a}) JE> $h{$a} exists but $h{$b} doesn't ===> -1 JE> $h{$a} does't exist but $h{$b} does ===> 1 JE> Neither $h{$a} nor $h{$b} exists ===> 0 EP> I beg to differ. Jurgen is right that OP must get realtional and EP> equality operators and boolean algebra straight first (as if mine is). EP> sort { EP> (exists $h{$a} xor exists $h{$b}) ? EP> exists $h{$b} - exists $h{$a} : EP> 0 EP> } @ks and where does that sort the lengths? even though it isn't a real requirement we all seem to have been using it. when you add that back you get much more complicated comparisons. i haven't even brought up speed for which the presort key extraction is needed. see my other post for an example which should work if i typed it cleanly and is simpler, clearer and faster. uri [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Sorting based on existence of keys
Top