[Koha-patches] [PATCH] Update holdings sort to sort by items.enumchron if there's no serial record and the biblio.serial flag is set.

Joe Atzberger joe.atzberger at liblime.com
Fri Jul 25 17:47:13 CEST 2008


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

On Fri, Jul 25, 2008 at 11:39 AM, Joe Atzberger <joe.atzberger at liblime.com>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20080725/12e859a1/attachment-0002.htm>


More information about the Koha-patches mailing list