summary refs log tree commit diff
path: root/bin/bibsort.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bibsort.pl')
-rw-r--r--bin/bibsort.pl5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/bibsort.pl b/bin/bibsort.pl
index 89133c87..a4a8956a 100644
--- a/bin/bibsort.pl
+++ b/bin/bibsort.pl
@@ -26,7 +26,7 @@ while (<>) {
 sub byLast {
 	my ($af, $al) = split /\s(\S+)(,.*)?$/, $a;
 	my ($bf, $bl) = split /\s(\S+)(,.*)?$/, $b;
-	$al cmp $bl || $af cmp $bf;
+	($al // $af) cmp ($bl // $bf) || $af cmp $bf;
 }
 
 foreach $ref (@refs) {
@@ -42,8 +42,9 @@ foreach $ref (@refs) {
 }
 
 sub byAuthor {
+	my ($ta, $tb) = ($a->{T}[0], $b->{T}[0]);
 	local ($a, $b) = ($a->{A}[0], $b->{A}[0]);
-	byLast();
+	byLast() || $ta cmp $tb;
 }
 
 {