Original answer
This is quite an interesting edge case.
The alpha-based .bst files actually use slightly different labels for sorting and for citations. The sorting label sort.label is made up of the letter combination and the four-digit year, while the citation label label is made up of the letter combination and the last two digits of the year.
So both entries in the MWE have the label Ber89, but Bertrand-CalculDesProbabilites has sort.label ber1889 and Bergstra_89 has sort.label ber1989.
Interestingly, the extra.label information to avoid name clashes is calculated based on the sort.label, even though only the cite labels will be visible in the document. Because the sort.labels differ, no extra.label is added. (NB: This is true, but it is not the whole story. The sorting itself also plays a role. See the longer explanation below.)
A simple solution is to make sure label and sort.label are the same. That can be done by replacing the entire definition of FUNCTION {calc.label} with
FUNCTION {calc.label}
{ type$ "book" =
type$ "inbook" =
or
'author.editor.key.label
{ type$ "proceedings" =
'editor.key.organization.label
{ type$ "manual" =
'author.key.organization.label
'author.key.label
if$
}
if$
}
if$
year field.or.null purify$ #-1 #2 substring$
*
duplicate$
'label :=
sortify 'sort.label :=
}
The extended MWE
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[USenglish,french,main=ngerman]{babel}
\usepackage{csquotes}
\usepackage{babelbib}
\usepackage{hyperref}
\bibliographystyle{babalpha-fl-gs}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Bertrand-CalculDesProbabilites,
title = {Calcul des probabilit{\'e}s},
author = {Joseph Bertrand},
year = 1889,
publisher = {Gauthier-Villars},
language = {french}
}
@book{Bergstra_89,
author = {Jan Aldert Bergstra},
isbn = {0-201-41635-2},
note = {Editors: J. Heering and P. Klint},
publisher = {ACM Press and Addison-Wesley},
series = {ACM Press Frontier Series},
title = {Algebraic specification},
year = {1989},
language = {USenglish},
}
@book{Bertrand-90,
title = {Calcul des probabilit{\'e}s II: Return of the Kolmogorov},
author = {Joseph Bertrand},
year = 1890,
publisher = {Gauthier-Villars},
language = {french}
}
\end{filecontents}
\begin{document}
\cite{Bertrand-CalculDesProbabilites,Bergstra_89,Bertrand-90}
\bibliography{\jobname}
\end{document}
will then produce
![[Ber89a] Jan Aldert Bergstra: Algebraic specification. ACM Press Frontier Series. ACM Press and Addison-Wesley, 1989, ISBN 0-201-41635-2. Editors: J. Heering and P. Klint.//[Ber89b] Joseph Bertrand: Calcul des probabilités. Gauthier-Villars, 1889.//[Ber90] Joseph Bertrand: Calcul des probabilités II : Return of the Kolmogorov. Gauthier-Villars, 1890.](../../images/dee4e1ecb09e47c596ef976a13453d58.webp)
About the edited question.
Sorting alphabetic bibliographies is tricky.
The straightforward sorting method of ordering by the alphabetic labels as seen in the document first and then by adding additional information (let's say name, year, title in that order) to break a tie produces output that some may find objectionable when different centuries are involved
[Elk02] Anne Elk: A Theory on Einiosauruses. 2002
[Elk99] Anne Elk: A Theory on Brontosauruses. 1999.
The people who don't like this output argue that the chronological order should override the strictly "label"-based sorting. That's why alpha actually sorts using the alphabetic part of the label and four digits of the year instead of the two that are shown in the output.
It would be interesting to hear what sort order would be desired for the following entries
[Uth02] Alice Uthor: A Book. 2002.
[Uth03] Emma Uthrinson: B Book 2003.
[Uth04] Alice Uthor: Another Book. 2004.
[Uth05] Emma Uthrinson: Bn Book. 2005.
If you normally argue that the whole year should beat the label to keep works of the same author in chronological order, you may be more inclined to keep works of the same author together and would have to accept that in those cases the author name should beat the label again.
In the end that could lead to a sorting scheme that gives precedence to full names and year over the actual citation label. While that would be more attractive to those who are very familiar with the references in the bibliography (i.e. the author of the bibliography), because works by the same author are kept together and in chronological order, it might be harder to navigate for the (as yet uninformed) reader, who only has the alphabetic labels to go on. I probably can't argue that there is a real risk that a reader would not manage to find the correct citation label when the sorting is more or less decoupled from the only bit of information she has (namely the label), but it is not inconceivable that she would have to spend a bit more time finding the right reference in a large bibliography with several works by authors with similar name abbreviations.
No matter which non-strictly-label-based sorting you go for, you always risk a situation where two labels of the same base form are separated by a different label
[Ber89] Victoria Bergman: Title. 1889.
[Ber90] Victoria Bergman: Title. 1890.
[Ber89] Sophie Bergstra: Title. 1989.
The way alpha and other BibTeX styles based on alpha.bst assign the extra label disambiguation labels is very susceptible for situations like this. It works as follows.
BibTeX iterates over the list of sorted entries (where sorted means sorted as the entries would appear in the bibliography). At each entry it checks if the base sort label (e.g. Ber1889) is the same as the previous base sort label. If that is the case, a counter is incremented and an extra.label letter is added. (BibTeX then has to do a reverse pass to make sure to add 'a' to each first entry with the same base-label. – It couldn't do that in the first step because at the point the first item with a particular label is processed it is not clear whether it will remain the only item with that base label.)
Note that this happens in a very simple loop where only the previous label is remembered. There is no list of all previous labels.
Therefore this method breaks down when the same base labels are passed to BibTeX with a different label in between. In Ber89, Ber90, Ber89 the previous and current label always differ (even if we only look at the label and not the sort label), hence no extra label is generated.
We can try to work around this problem by decoupling the extra label iteration from the actual sorting for the bibliography. First we sort the items by their visible label to generate a list where the same labels follow each other. Based on that list we generate the extra.label. Then we sort the entries for the bibliography using the sort labels.
The diff (against the original babalpha-fl-gs.bst from https://tex.stackexchange.com/a/441877/35864 and https://gist.github.com/moewew/158481168f4a2135764f96fc608a1998) for the required changes is
--- babalpha-fl-gs.bst 2019-02-02 13:38:29.856655800 +0100
+++ babalpha-fl-gs-sort.bst 2019-02-02 13:40:07.936905700 +0100
@@ -1,3 +1,11 @@
+%%%%%% `babalpha-fl-gs-sort.bst'
+%%%%%% babalpha-fl-gs with tweaked sorting
+%%%%%% for https://tex.stackexchange.com/q/472951/35864
+%%%%%% 2019-02-02 MW
+%%%%%% available at
+%%%%%% https://gist.github.com/moewew/6a59fc23db6d2ab219b6f189a3645a06
+%%%%%% header of `babalpha-fl-gs.bst' follows
+%%%%%%
%%%% `babalpha-fl-gs.bst'
%%%% a copy of `babalpha-fl.bst' that automatically tries to suppress
%%%% historically problematic abbreviations
@@ -59,7 +67,7 @@
year
}
{}
- { label extra.label sort.label }
+ { label extra.label sort.label real.sortkey }
INTEGERS
{ output.state
@@ -1498,7 +1506,9 @@
if$
}
-FUNCTION {presort}
+% label generation: extra label
+
+FUNCTION {calc.real.sortkey}
{
calc.label
sort.label
@@ -1529,10 +1539,22 @@
sort.format.title
*
#1 entry.max$ substring$
+ 'real.sortkey :=
+}
+
+FUNCTION {labelgenpresort}
+{
+ calc.real.sortkey
+ label
+ " "
+ *
+ real.sortkey
+ *
+ #1 entry.max$ substring$
'sort.key$ :=
}
-ITERATE {presort}
+ITERATE {labelgenpresort}
SORT
@@ -1549,13 +1571,13 @@
}
FUNCTION {forward.pass}
-{ last.sort.label sort.label =
+{ last.sort.label label =
{ last.extra.num #1 + 'last.extra.num :=
last.extra.num int.to.chr$ 'extra.label :=
}
{ "a" chr.to.int$ 'last.extra.num :=
"" 'extra.label :=
- sort.label 'last.sort.label :=
+ label 'last.sort.label :=
}
if$
}
@@ -1580,6 +1602,18 @@
ITERATE {forward.pass}
REVERSE {reverse.pass}
+% actual sorting
+
+FUNCTION {presort}
+{
+ real.sortkey
+ 'sort.key$ :=
+}
+
+ITERATE {presort}
+
+SORT
+
FUNCTION {begin.bib}
{
et.al.char.used
The new file babalpha-fl-gs-sort.bst can be found at https://gist.github.com/moewew/6a59fc23db6d2ab219b6f189a3645a06
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[USenglish,french,main=ngerman]{babel}
\usepackage{csquotes}
\usepackage{babelbib}
\usepackage{hyperref}
\bibliographystyle{babalpha-fl-gs-sort}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@string{acmp = {ACM Press}}
@string{aw = {Addison-Wesley}}
@string{ol = {Oldenbourg Wissenschaftsverlag}}
@string{pren = {Prentice Hall}}
@book{Bertrand-CalculDesProbabilites,
title = {Calcul des probabilit{\'e}s},
author = {Joseph Bertrand},
year = 1889,
publisher = {Gauthier-Villars},
language = {french},
}
@book{Bergstra_89,
author = {Jan Aldert Bergstra},
isbn = {0-201-41635-2},
language = {USenglish},
note = {Editors: J. Heering and P. Klint},
publisher = acmp # { and } # aw,
series = {ACM Press Frontier Series},
title = {Algebraic specification},
year = {1989},
}
@book{Eckel_99,
author = {Bruce Eckel},
language = {USenglish},
publisher = pren,
title = {Thinking in {C++}},
year = 1999,
}
@book{Eckel_02,
author = {Bruce Eckel},
language = {USenglish},
publisher = pren,
title = {Thinking in {Java}},
year = {2002},
}
@misc{BroyEtAl-ModellierungVerteilterSysteme,
author = {Manfred Broy},
language = {ngerman},
note = {Vorlesungsskript},
title = {Modellierung verteilter Systeme},
year = 2014,
}
@book{Brooks_87,
author = {Rodney Allen Brooks},
language = {ngerman},
publisher = ol,
title = {{LISP}: Programmieren in Common {Lisp}},
year = 1987,
}
@book{Bertrand-90,
title = {Calcul des probabilit{\'e}s II: Return of the Kolmogorov},
author = {Joseph Bertrand},
year = 1890,
publisher = {Gauthier-Villars},
language = {french},
}
\end{filecontents}
\begin{document}
\nocite{*}
\cite{Bertrand-CalculDesProbabilites,Bergstra_89,Bertrand-90}
\bibliography{\jobname}
\end{document}
produces
![[Ber89a] Joseph Bertrand: Calcul des probabilités. Gauthier-Villars, 1889.//[Ber90] Joseph Bertrand: Calcul des probabilités II : Return of the Kolmogorov. Gauthier-Villars, 1890.//[Ber89b] Jan Aldert Bergstra: Algebraic specification. ACM Press Frontier Series. ACM Press and Addison-Wesley, 1989, ISBN 0-201-41635-2. Editors: J. Heering and P. Klint.//[Bro87] Rodney Allen Brooks: LISP: Programmieren in Common Lisp. Oldenbourg Wissenschaftsverlag, 1987.//[Bro14] Manfred Broy: Modellierung verteilter Systeme, 2014. Vorlesungsskript.//[Eck99] Bruce Eckel: Thinking in C++. Prentice Hall, 1999.//[Eck02] Bruce Eckel: Thinking in Java. Prentice Hall, 2002.](../../images/c07f694dd1888805bd0f9af03152f637.webp)
babelalpha-flas well. (edit: Turns outalpha.bsthas the same issue, ...) – moewe Feb 01 '19 at 20:52Joseph Bertrandfrom1890: [Ber89a], [Ber90], [Ber89b] (chronological) or [Ber89a], [Ber89b], [Ber90] (sorted only by the alphabetic label)? – moewe Feb 01 '19 at 21:07