Sorry, that got sent before I was done editing it.

On Fri, Jul 25, 2008 at 11:39 AM, Joe Atzberger <[EMAIL PROTECTED]>
wrote:
Is there a problem when one item has publisheddate and another only has
enumchron?  I still don't really understand enumchron, but I think we want a
failover between two sets of comparisons, not two failovers of criteria.
That is, unless I misunderstand and  publisheddate and enumchron really are
interchangeable to that degree.  Can you confirm, Ryan?

Otherwise I would propose something like :
sub sort_pubdate {
    my $key = 'publisheddate';
    $b->{$key} and $a->{$key} or return 0;
    $b->{$key} cmp $a->{$key};
}
sub sort_enum    {
    my $key = 'enumchron';
    $b->{$key} and $a->{$key} or return 0;
    $b->{$key} cmp $a->{$key};
}
sub sort_either   {
    ($b->{publisheddate} || $b->{enumchron})
                    cmp
    ($a->{publisheddate} || $a->{enumchron})   ;
}
...
return( sort {&sort_pubdate || &sort_enum || &sort_either } @results );

--joe
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to