/[webpac]/trunk2/lib/WebPAC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk2/lib/WebPAC.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 440 by dpavlin, Mon Sep 13 23:13:54 2004 UTC revision 441 by dpavlin, Tue Sep 14 17:07:59 2004 UTC
# Line 754  sub fill_in_to_arr { Line 754  sub fill_in_to_arr {
754          return @arr;          return @arr;
755  }  }
756    
757    =head2 sort_arr
758    
759    Sort array ignoring case and html in data
760    
761     my @sorted = $webpac->sort_arr(@unsorted);
762    
763    =cut
764    
765    sub sort_arr {
766            my $self = shift;
767    
768            my $log = $self->_get_logger();
769    
770            # FIXME add Schwartzian Transformation?
771    
772            my @sorted = sort {
773                    $a =~ s#<[^>]+/*>##;
774                    $b =~ s#<[^>]+/*>##;
775                    lc($b) cmp lc($a)
776            } @_;
777            $log->debug("sorted values: ",sub { join(", ",@sorted) });
778    
779            return @sorted;
780    }
781    
782    
783  =head2 data_structure  =head2 data_structure
784    
# Line 811  sub data_structure { Line 836  sub data_structure {
836                          next if (! @v);                          next if (! @v);
837    
838                          if ($tag->{'sort'}) {                          if ($tag->{'sort'}) {
839                                  # very special sort, ignoring case and                                  @v = $self->sort_arr(@v);
                                 # html  
                                 @v = sort {  
                                         $a =~ s#<[^>]+/*>##;  
                                         $b =~ s#<[^>]+/*>##;  
                                         lc($b) cmp lc($a)  
                                 } @v;  
840                                  $log->warn("sort within tag is usually not what you want!");                                  $log->warn("sort within tag is usually not what you want!");
                                 $log->debug("sorted values: ",sub { join(", ",@v) });  
841                          }                          }
842    
843                          # use format?                          # use format?
# Line 880  sub data_structure { Line 898  sub data_structure {
898                          # post-sort all values in field                          # post-sort all values in field
899                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {
900                                  $log->warn("sort at field tag not implemented");                                  $log->warn("sort at field tag not implemented");
   
901                          }                          }
902    
903                          push @ds, $row;                          push @ds, $row;

Legend:
Removed from v.440  
changed lines
  Added in v.441

  ViewVC Help
Powered by ViewVC 1.1.26