From: dpvc v. a. <we...@ma...> - 2005-07-04 19:42:41
|
Log Message: ----------- Fixed problem with sorting (problem with $a, $b, I think). Modified Files: -------------- pg/lib/Parser/Context: Strings.pm Revision Data ------------- Index: Strings.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Strings.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/Parser/Context/Strings.pm -Llib/Parser/Context/Strings.pm -u -r1.5 -r1.6 --- lib/Parser/Context/Strings.pm +++ lib/Parser/Context/Strings.pm @@ -28,7 +28,7 @@ my $self = shift; my $data = $self->{context}->{$self->{dataName}}; my $single = ''; my @multi = (); - foreach my $x (sort Value::Context::Data::byName (keys %{$data})) { + foreach my $x (sort byName (keys %{$data})) { unless ($data->{$x}{hidden}) { if ($data->{$x}{caseSensitive} || uc($x) eq lc($x)) { if (length($x) == 1) {$single .= $x} @@ -44,6 +44,16 @@ } # +# Must be in the same package as the sort call +# (due to global $a and $b, I assume) +# +sub byName { + my $result = length($b) <=> length($a); + return $result unless $result == 0; + return $a cmp $b; +} + +# # Same as Value::Context::Data::getPattern, but with # the protectRegexp already done on the @multi list. # |