summaryrefslogtreecommitdiff
path: root/doc/scripts/sort1.pl
diff options
context:
space:
mode:
Diffstat (limited to 'doc/scripts/sort1.pl')
-rwxr-xr-xdoc/scripts/sort1.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/scripts/sort1.pl b/doc/scripts/sort1.pl
new file mode 100755
index 0000000000..9d31ed4e81
--- /dev/null
+++ b/doc/scripts/sort1.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+sub key_of_record {
+ local($record) = @_;
+
+ # Split record into lines:
+ my @lines = split /\n/, $record;
+
+ my ($i) = 1;
+ my ($key) = $lines[$i];
+
+ while( !($key =~ m/^\\label(.*)/) && ($i < 5)) { $i=$i+1; $key = $lines[$i]; }
+
+ return $key;
+}
+
+$/="\n\n\n"; # Records are separated by blank lines.
+@records = <>; # Read in whole file, one record per array element.
+
+@records = sort { key_of_record($a) cmp key_of_record($b) } @records;
+print @records;