[Tex/LaTex] elsarticle: How to get bibliography sorted alphabetically

bibliographieselsarticlenatbib

How can one get the bibliography items to appear in alphabetical order (by last name) in elsarticle (based on Natbib afaik). Below is a MWE. The expected outcome is the two entries appearing interchanged (so 'F. Bar' before 'B. Foo').

\documentclass[times, sort&compress, 3p]{elsarticle}
\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
@article{mykey1,
   author = {Foo, B.},
   journal = {Journal of LaTeX questions},
   pages = {1--10},
   title = {{Minimal title}},
   volume = {1},
   number = {1},
   year = {2017}}
@article{mykey2,
   author = {Bar, F.},
   journal = {Journal of LaTeX questions},
   pages = {1--10},
   title = {{Minimal title}},
   volume = {1},
   number = {1},
   year = {2011}}
\end{filecontents*}
\begin{document}
\cite{mykey1}, \cite{mykey2}
\bibliographystyle{elsarticle-num}
\bibliography{bib}
\end{document}

Best Answer

The elsarticle-num bib style does not perform alphabetical sorting. If you don't have to use this bib style; don't.

For an alternative to elsarticle-num, you might consider the abbrvnat bib style. If you do so, be sure to also specify the document class option numbers (which will be passed to the natbib package).

Related Question