Name

sort_ary —

ATTRIBUTES

Attribute Pos. Req. Default Description
interpolate     0 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

No examples are available at this time. We do consider this a problem and will try to supply some.

NOTES

AVAILABILITY

sort_ary is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: lib/Vend/Interpolate.pm
Lines: 3016

sub tag_sort_ary {
  my($opts, $list) = (@_); 
  $opts =~ s/^\s+//; 
  $opts =~ s/\s+$//; 
#::logDebug("tag_sort_ary: opts=$opts list=" . uneval($list));
my @codes;
my $key = 0;

my ($start, $end, $num);
my $glob_opt = 'none';

  my @opts =  split /\s+/, $opts;
  my @option; my @bases; my @fields;

  for(@opts) {
      my ($base, $fld, $opt) = split /:/, $_;

  if($base =~ /^(\d+)$/) {
    $key = $1;
    $glob_opt = $fld || $opt || 'none';
    next;
  }
  if($base =~ /^([-=+])(\d+)-?(\d*)/) {
    my $op = $1;
    if    ($op eq '-') { $start = $2 }
    elsif ($op eq '+') { $num   = $2 }
    elsif ($op eq '=') {
      $start = $2;
      $end = ($3 || undef);
    }
    next;
  }
  
      push @bases, $base;
      push @fields, $fld;
      push @option, (defined $Vend::Interpolate::Sort_field{$opt} ? $opt : 'none');
  }

if(defined $end) {
  $num = 1 + $end - $start;
  $num = undef if $num < 1;
 }

  my $i;
  my $routine = 'sub { ';
for( $i = 0; $i < @bases; $i++) {
    $routine .= '&{$Vend::Interpolate::Sort_field{"' .
          $option[$i] .
          '"}}(' . "\n";
    $routine .= "tag_data('$bases[$i]','$fields[$i]', \$_[0]->[$key]),\n";
    $routine .= "tag_data('$bases[$i]','$fields[$i]', \$_[1]->[$key]) ) or ";
}
$routine .= qq!0 or &{\$Vend::Interpolate::Sort_field{"$glob_opt"}}!;
$routine .= '($_[0]->[$key],$_[1]->[$key]); }';
#::logDebug("tag_sort_ary routine: $routine\n");

  my $code = eval $routine;  
  die "Bad sort routine\n" if $@;

#Prime the sort? Prevent variable suicide??
#&{$Vend::Interpolate::Sort_field{'n'}}('31', '30');

use locale;
if($::Scratch->{mv_locale}) {
  POSIX::setlocale(POSIX::LC_COLLATE(),
    $::Scratch->{mv_locale});
}

@codes = sort {&$code($a, $b)} @$list;

if($start > 1) {
  splice(@codes, 0, $start - 1);
}

if(defined $num) {
  splice(@codes, $num);
}
#::logDebug("tag_sort_ary routine returns: " . uneval(\@codes));
return \@codes;
}

AUTHORS

Interchange Development Group

SEE ALSO

DocBook! Interchange!