You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by jo...@apache.org on 2011/07/05 17:52:31 UTC
svn commit: r1143112 - /incubator/ooo/site/trunk/lib/view.pm
Author: joes
Date: Tue Jul 5 15:52:31 2011
New Revision: 1143112
URL: http://svn.apache.org/viewvc?rev=1143112&view=rev
Log:
support numeric sort with "n" marker
Modified:
incubator/ooo/site/trunk/lib/view.pm
Modified: incubator/ooo/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/incubator/ooo/site/trunk/lib/view.pm?rev=1143112&r1=1143111&r2=1143112&view=diff
==============================================================================
--- incubator/ooo/site/trunk/lib/view.pm (original)
+++ incubator/ooo/site/trunk/lib/view.pm Tue Jul 5 15:52:31 2011
@@ -179,7 +179,7 @@ sub sort_tables {
while (defined(local $_ = shift @orig)) {
push @out, $_;
/^(\|[ :v^-]+)+\|$/ or next;
- my($col, $direction, $cur);
+ my($col, $direction, $cur, $numeric);
$cur = 0;
while (/\|([ :v^-]+)/g) {
my $data = $1;
@@ -199,11 +199,14 @@ sub sort_tables {
push @out, shift @orig while @orig and $orig[0] =~ /^\|/;
next;
}
+ $numeric = 1 if $1 =~ tr/n/n/;
my @rows;
push @rows, [split /\s*\|\s*/, shift(@orig), -1]
while @orig and $orig[0] =~ /^\|/;
shift @$_, pop @$_ for @rows; # dump empty entries at ends
- @rows = sort { $a->[$col] cmp $b->[$col] } @rows;
+ @rows = $numeric
+ ? sort { $a->[$col] <=> $b->[$col] } @rows
+ : sort { $a->[$col] cmp $b->[$col] } @rows;
@rows = reverse @rows if $direction == -1;
push @out, map "| " . join(" | ", @$_) . " |", @rows;
}