Changeset 13551


Ignore:
Timestamp:
2007-01-10T14:16:43+13:00 (17 years ago)
Author:
mdewsnip
Message:

Added a new option: sort_using_unicode_collation, which uses the Unicode::Collate module to sort Unicode values better (eg. e with acute is sorted with the other e values, not after everything else).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/GenericList.pm

    r13550 r13551  
    6868    'type' => "metadata",
    6969    'deft' => "Title" },
     70      { 'name' => "sort_using_unicode_collation",
     71    'desc' => "{GenericList.sort_using_unicode_collation}",
     72    'type' => "flag" },
    7073      { 'name' => "use_hlist_for",
    7174    'desc' => "{GenericList.use_hlist_for}",
     
    160163    }
    161164    $self->{'sort_leaf_nodes_using_metadata_groups'} = \@sort_leaf_nodes_using_metadata_groups;
     165
     166    # Create an instance of the Unicode::Collate object if better Unicode sorting is desired
     167    if ($self->{'sort_using_unicode_collation'}) {
     168    require Unicode::Collate;
     169    $self->{'unicode_collator'} = Unicode::Collate->new();
     170    }
    162171
    163172    # An empty array for the document OIDs
     
    309318    if ($partition_type_within_level =~ /^per_letter$/i) {
    310319    # Generate one hlist for each letter
    311     my @sortedmetavalues = sort(keys %metavaluetoOIDhash);
     320    my @sortedmetavalues = &sort_metadata_values_array($self, keys(%metavaluetoOIDhash));
    312321    my %metavaluetoOIDsubhash = ();
    313322
     
    337346    my $partition_size_within_level = $self->{$metadata_group . ".partition_size_within_level"};
    338347    if ($partition_type_within_level =~ /^constant_size$/i && scalar(keys %metavaluetoOIDhash) > $partition_size_within_level) {
    339         my @sortedmetavalues = sort(keys %metavaluetoOIDhash);
     348        my @sortedmetavalues = &sort_metadata_values_array($self, keys(%metavaluetoOIDhash));
    340349        my $itemsdone = 0;
    341350        my %metavaluetoOIDsubhash = ();
     
    471480
    472481    # Create an entry in the vlist for each value
    473     foreach my $metavalue (sort(keys %metavaluetoOIDhash)) {
     482    foreach my $metavalue (&sort_metadata_values_array($self, keys(%metavaluetoOIDhash))) {
    474483    my @OIDs = @{$metavaluetoOIDhash{$metavalue}};
    475484
     
    526535
    527536
     537sub sort_metadata_values_array
     538{
     539    my $self = shift(@_);
     540    my @metadata_values = @_;
     541
     542    if ($self->{'unicode_collator'}) {
     543    return $self->{'unicode_collator'}->sort(@metadata_values);
     544    }
     545    else {
     546    return sort(@metadata_values);
     547    }
     548}
     549
     550
    5285511;
Note: See TracChangeset for help on using the changeset viewer.