User:Jheald/BCbot/tem sort.pl
From Wikipedia, the free encyclopedia
$ct=0; while (<>) { chomp; if (/^Image:/) {$img = $_;next} if (/^Template:/) {$ct++; $tem{$ct}=$_; $img{$ct}=$img} } $last_tem=''; sub by_tem {(($tem{$a} cmp $tem{$b}) || ($img{$a} cmp $img{$b}))} foreach $ct (sort by_tem (keys(%tem))) { if ($tem{$ct} ne $last_tem) {print"\n== [[:$tem{$ct}]] ==\n"; $last_tem=$tem{$ct}}; print ":[[:$img{$ct}]]\n"; }