--- trunk2/lib/WebPAC.pm 2004/09/13 23:13:54 439 +++ trunk2/lib/WebPAC.pm 2004/09/14 17:07:59 441 @@ -754,6 +754,31 @@ return @arr; } +=head2 sort_arr + +Sort array ignoring case and html in data + + my @sorted = $webpac->sort_arr(@unsorted); + +=cut + +sub sort_arr { + my $self = shift; + + my $log = $self->_get_logger(); + + # FIXME add Schwartzian Transformation? + + my @sorted = sort { + $a =~ s#<[^>]+/*>##; + $b =~ s#<[^>]+/*>##; + lc($b) cmp lc($a) + } @_; + $log->debug("sorted values: ",sub { join(", ",@sorted) }); + + return @sorted; +} + =head2 data_structure @@ -811,15 +836,8 @@ next if (! @v); if ($tag->{'sort'}) { - # very special sort, ignoring case and - # html - @v = sort { - $a =~ s#<[^>]+/*>##; - $b =~ s#<[^>]+/*>##; - lc($b) cmp lc($a) - } @v; + @v = $self->sort_arr(@v); $log->warn("sort within tag is usually not what you want!"); - $log->debug("sorted values: ",sub { join(", ",@v) }); } # use format? @@ -880,7 +898,6 @@ # post-sort all values in field if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) { $log->warn("sort at field tag not implemented"); - } push @ds, $row;