Minor Bug Fixing NZorder showed inverted orders for some indexes.
authorHenri-Damien LAURENT <henridamien@koha-fr.org>
Mon, 19 Nov 2007 10:06:54 +0000 (11:06 +0100)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 20 Nov 2007 22:19:39 +0000 (16:19 -0600)
sort {$a cmp $b} @array is the same as sort @array
But sort {$b cmp $a} @array reverse order.
+ Adapting GetMarcFromKohaField to new signature.

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Search.pm

index c82a148..bfc00d1 100644 (file)
@@ -1413,11 +1413,11 @@ sub NZorder {
         my $result_hash;
         my $numbers=0;
         if ($ordering eq 'author_za') { # sort by author desc
-            foreach my $key (sort (keys %result)) {
+            foreach my $key (sort { $b cmp $a } (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key}->as_usmarc();
             }
         } else { # sort by author ASC
-            foreach my $key (sort { $a cmp $b } (keys %result)) {
+            foreach my $key (sort (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key}->as_usmarc();
             }
         }
@@ -1449,7 +1449,7 @@ sub NZorder {
         my $result_hash;
         my $numbers=0;
         if ($ordering eq 'call_number_dsc') { # sort by title desc
-            foreach my $key (sort (keys %result)) {
+            foreach my $key (sort { $b cmp $a } (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key}->as_usmarc();
             }
         } else { # sort by title ASC
@@ -1466,7 +1466,7 @@ sub NZorder {
         foreach (split /;/,$biblionumbers) {
             my ($biblionumber,$title) = split /,/,$_;
             my $record=GetMarcBiblio($biblionumber);
-            my ($publicationyear_tag,$publicationyear_subfield)=GetMarcFromKohaField($dbh,'biblioitems.publicationyear');
+            my ($publicationyear_tag,$publicationyear_subfield)=GetMarcFromKohaField('biblioitems.publicationyear','');
             my $publicationyear=$record->subfield($publicationyear_tag,$publicationyear_subfield);
             # hint : the result is sorted by title.biblionumber because we can have X biblios with the same title
             # and we don't want to get only 1 result for each of them !!!
@@ -1476,11 +1476,11 @@ sub NZorder {
         my $result_hash;
         my $numbers=0;
         if ($ordering eq 'pubdate_dsc') { # sort by pubyear desc
-            foreach my $key (sort (keys %result)) {
+            foreach my $key (sort { $b cmp $a } (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key}->as_usmarc();
             }
         } else { # sort by pub year ASC
-            foreach my $key (sort { $b cmp $a } (keys %result)) {
+            foreach my $key (sort (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key}->as_usmarc();
             }
         }
@@ -1505,7 +1505,7 @@ sub NZorder {
         # sort the hash and return the same structure as GetRecords (Zebra querying)
         my $result_hash;
         my $numbers=0;
-        if ($ordering eq 'title_za') { # sort by title desc
+        if ($ordering eq 'title_az') { # sort by title desc
             foreach my $key (sort (keys %result)) {
                 $result_hash->{'RECORDS'}[$numbers++] = $result{$key};
             }