Tizen 2.0 Release
[external/libgnutls26.git] / doc / scripts / sort2.pl
1 #!/usr/bin/perl
2
3 sub key_of_record {
4   local($record) = @_;
5
6   # Split record into lines:
7   my @lines = split /\n/, $record;
8
9   my ($i) = 1;
10   my ($key) = $lines[$i];
11
12   while( !($key =~ /^\@deftypefun/) && ($i < 5)) { $i=$i+1; $key = $lines[$i]; }
13
14   $key = $1 if $key =~ /^\@deftypefun {.*} {(.*)}/;
15
16 #  print STDERR "key $1\n";
17
18   return $key;
19 }
20
21 $/="@end deftypefun";          # Records are separated by blank lines.
22 @records = <>;  # Read in whole file, one record per array element.
23
24 @records = sort { key_of_record($a) cmp key_of_record($b) } @records;
25 print @records;