Ignore:
Timestamp:
2000-07-14T12:24:20+12:00 (24 years ago)
Author:
sjboddie
Message:

Implemented a -sortmeta option for import.pl to sort archives.inf file
(generated at end of import process) alphabetically by the given
metadata element. This may be useful for some collections as boolean
queries currently return matches in build (fairly random) order. Changing
the order of archives.inf changes the order that documents are built.
This option has a couple of important limitations:

  1. Can't be used in conjunction with the groupsize option as it would then only change the build order of groups of documents which doesn't seem very useful.
  2. Is of limited use when building indexes at a section level as the build order is only sorted by document, not by section.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/arcinfo.pm

    r537 r1287  
    9393    my $i = 0;
    9494    while ($i < scalar (@{$self->{'order'}})) {
    95         if ($self->{'order'}->[$i] eq $OID) {
     95        if ($self->{'order'}->[$i]->[0] eq $OID) {
    9696        splice (@{$self->{'order'}}, $i, 1);
    9797        last;
     
    105105sub add_info {
    106106    my $self = shift (@_);
    107     my ($OID, $doc_file) = @_;
     107    my ($OID, $doc_file, $sortmeta) = @_;
     108    $sortmeta = "" unless defined $sortmeta;
    108109
    109110    $self->delete_info ($OID);
    110111    $self->{'info'}->{$OID} = [$doc_file];
    111     push (@{$self->{'order'}}, $OID);
     112    push (@{$self->{'order'}}, [$OID, $sortmeta]);
    112113}
    113114
     
    119120    my @list = ();
    120121
    121     foreach $OID (@{$self->{'order'}}) {
    122     push (@list, [$OID, $self->{'info'}->{$OID}->[0]]);
     122    foreach $OID (sort {$a->[1] cmp $b->[1]} @{$self->{'order'}}) {
     123    push (@list, [$OID->[0], $self->{'info'}->{$OID->[0]}->[0]]);
    123124    }
    124125
     
    133134    my @list = ();
    134135
    135     foreach $OID (@{$self->{'order'}}) {
    136     push (@list, [$self->{'info'}->{$OID}->[0], $OID]);
     136    foreach $OID (sort {$a->[1] cmp $b->[1]} @{$self->{'order'}}) {
     137    push (@list, [$self->{'info'}->{$OID->[0]}->[0], $OID->[0]]);
    137138    }
    138139
Note: See TracChangeset for help on using the changeset viewer.