[Koha-patches] [PATCH] Fixing 2516 : Ordering names with multiple keys

Joe Atzberger joe.atzberger at liblime.com
Wed Aug 27 17:09:08 CEST 2008


On Wed, Aug 27, 2008 at 10:31 AM, Galen Charlton <galen.charlton at liblime.com
> wrote:

> Hi Henri,
>
> On Fri, Aug 22, 2008 at 10:19 AM, Henri-Damien LAURENT
> <henridamien.laurent at biblibre.com> wrote:
> > +    $orderby.=",firstname,othernames" if $orderby=~/name/;
>
> I'm not sure how this patch fixes bug 2516 as described.  The
> SearchMember call in circ/circulation.pl uses 'cardnumber' for
> $orderby; furthermore, around line 529 of circ/circulation.pl, the
> results of the SearchMember call are sorted again anyway:
>
>    foreach (
>        sort {
>                lc $a->{'surname'}
>              . lc $a->{'firstname'} cmp lc $b->{'surname'}
>              . lc $b->{'firstname'}
>        } @$borrowerslist
>      )
>
> Perhaps the fix needs to be there?
>


That sort looks bogus at first glance.  Test script w/ simple array of
hashref:

#!/usr/bin/perl

my @list = (
{surname=>'Smithson', firstname=>'Jack'},
{surname=>'Smith', firstname=>'Jack'},
{surname=>'Smith', firstname=>'Abel'},
{surname=>'Smith', firstname=>'Zeke'},
);

 foreach (
       sort {
               lc $a->{'surname'}
             . lc $a->{'firstname'} cmp lc $b->{'surname'}
             . lc $b->{'firstname'}
       } @list
     ) { print $_->{'surname'}, ", ", $_->{'firstname'}, "\n"; }

Produces this output:

Smith, Abel
Smith, Jack
Smithson, Jack
Smith, Zeke

That's pretty clearly wrong.  The second "s" in Smithson is not equivalent
to "Smith, S..."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20080827/1fffca27/attachment-0005.htm>


More information about the Koha-patches mailing list