# Sort bib according to author last name in biber

Consider the following bibliography (MWE at the end) produced with

\usepackage[backend=biber,
citestyle=alphabetic,
bibstyle=alphabetic,
firstinits=true
]{biblatex}


As you can see there are three different authors, one present in all four papers.

Also, the alphabetical order is according to the label in brackets, that is, GM08,GM13,GM14a,GM14b.

But, I'd like to change it, that is, to sort according to author last names (not the label in brackets) so that the order should be:

GM13,GM14a,GM08,GM14b


since the sorting is (Gol, de Ma) < (Gol, Muk)

I agree that in this way the four labels could look not ordered since the years will change, but the same group of authors will produce grouped entries.

MWE

% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
\documentclass[british]{article}
\begin{filecontents*}{mybib.bib}
@article{faa,
title={Faa Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2008},
publisher={Institute}
}
@article{foo,
title={Foo Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}

@article{zaa,
title={Zaa Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2013},
publisher={Institute}
}
@article{zoo,
title={Zoo Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}
\end{filecontents*}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{csquotes}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


You need to add the option

  sorting=nty,


to biblatex to get a sorting first name, then title, then year.

See the corrected MWE

% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
\begin{filecontents*}{mybib.bib}
@article{faa,
title={Faa Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2008},
publisher={Institute}
}
@article{foo,
title={Foo Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}

@article{zaa,
title={Zaa Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2013},
publisher={Institute}
}
@article{zoo,
title={Zoo Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}
\end{filecontents*}

\documentclass[british]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{csquotes}
\usepackage[%
backend=biber,
citestyle=alphabetic,
bibstyle=alphabetic,
firstinits=true,
sorting=nty,  % <=====================================================
]{biblatex}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


and the result:

• So, can I use nyt? – Sigur Mar 16 at 17:59
• Oh, yes, @moewe suggested that. Anyway, thanks guys. – Sigur Mar 16 at 18:05

I suggest you use

style=alphabetic, sorting=nyt,


if you want items by the same set of authors grouped.

\documentclass[brazil]{article}
\begin{filecontents*}{\jobname.bib}
@article{faa,
title={Faa Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2008},
publisher={Institute}
}
@article{foo,
title={Foo Something important},
author={Mar Gol and Ju Muk},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}

@article{zaa,
title={Zaa Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2013},
publisher={Institute}
}
@article{zoo,
title={Zoo Something important},
author={Mar Gol and Ta de Ma},
journal={Prestigious Journal},
volume={47},
number={7},
pages={966--978},
year={2014},
publisher={Institute}
}
\end{filecontents*}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=alphabetic, sorting=nyt, giveninits=true]{biblatex}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


I have written about the difficulties of sorting alphabetic styles in Avoid ambiguity in bibliographies created with babalpha-fl. For the informed author it may be more attractive to override the pure sorting by the alphabetic label with a sorting scheme that takes into account the full list of author names as well as year and title as that keeps entries by the same set of authors together and ensures that entries are ordered chronologically. This approach can lead to labels that are not sorted alphabetically in the bibliography. Since those labels are the only thing the reader (who does not yet know what entry the label refers to) can go by, that could lead to confusion or slightly larger cognitive load. In the example it is not at all clear why GM08 should come after GM14a and why there is another entry between GM14a and GM14b. Usually that probably does not matter much, but if you had many works by several groups of authors with similar abbreviations with a page break in between, people might get confused at first and think the entries might be missing.

This sorting problem of alphabetic styles has brought me to believe that a numeric or author-year style is a better alternative.

• I agree with numeric style, but I don't know why with it the \ifkeyword approach you suggested me before does not work. I'm using it to insert a bullet in front of mine items. – Sigur Mar 16 at 18:23
• @Sigur Are you using labelnumberwidth (instead of labelalphawidth)? If it does not work, please ask a new question with an MWE that shows exactly what you are doing. – moewe Mar 16 at 19:01
• Oh, I see. When change to numeric, should be changed also the label... makes sense. Thanks. – Sigur Mar 16 at 19:35