Changeset 22667


Ignore:
Timestamp:
2010-08-18T13:19:55+12:00 (12 years ago)
Author:
mdewsnip
Message:

Added code to prevent uninitialized value errors when trying to sort on metadata fields that don't exist in the collection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/List.pm

    r22175 r22667  
    867867    # Force a stable sort (Perl 5.6's sort isn't stable)
    868868    # !! The [0] bits aren't ideal (multiple metadata values) !!
    869     @OIDs = @OIDs[ sort { $OID_to_metadata_values_hash_ref->{$OIDs[$a]}[0] cmp $OID_to_metadata_values_hash_ref->{$OIDs[$b]}[0] || $a <=> $b; } 0..$#OIDs ];
     869    @OIDs = @OIDs[ sort {
     870      if (defined($OID_to_metadata_values_hash_ref->{$OIDs[$a]} && defined($OID_to_metadata_values_hash_ref->{$OIDs[$b]})))
     871      {
     872        $OID_to_metadata_values_hash_ref->{$OIDs[$a]}[0] cmp $OID_to_metadata_values_hash_ref->{$OIDs[$b]}[0];
     873      }
     874      else
     875      {
     876        $a <=> $b;
     877      }
     878    } 0..$#OIDs ];
    870879    }
    871880    return @OIDs;
Note: See TracChangeset for help on using the changeset viewer.