incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1143112 - /incubator/ooo/site/trunk/lib/view.pm
Date Tue, 05 Jul 2011 15:52:31 GMT
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;
     }



Mime
View raw message