# Order references alphabetically with “elsarticle-num-names.bst”

How Can I order my references alphabetically using the bibliographystyle "elsarticle-num-names.bst"?

Here is a MWE, copied from the elsarticle template folder itself:

elsarticle-template.tex:

\documentclass[preprint]{elsarticle}

\journal{Journal of \LaTeX\ Templates}
\bibliographystyle{elsarticle-num-names}

\begin{document}

\begin{frontmatter}
\end{frontmatter}

Here are two sample references: \cite{Feynman1963118,Dirac1953888}.

\section*{References}
\bibliography{mybibfile}
\end{document}

mybibfile.bib:

@article{Dirac1953888,
title   = "The lorentz transformation and absolute time",
journal = "Physica ",
volume  = "19",
number  = "1-–12",
pages   = "888--896",
year    = "1953",
doi     = "10.1016/S0031-8914(53)80099-6",
author  = "P.A.M. Dirac"
}

@article{Feynman1963118,
title   = "The theory of a general quantum system interacting with a linear dissipative system",
journal = "Annals of Physics ",
volume  = "24",
pages   = "118--173",
year    = "1963",
doi     = "10.1016/0003-4916(63)90068-X",
author  = "R.P Feynman and F.L {Vernon Jr.}"
}

This style already uses the sorting function. You can edit sort function bib.sort.order in your .bst file. It is very good described on Bibtex .bst file modification to include alphabetical ordering. I hope it will help you.

• Finally I managed to do this! I had to copy, from the link you mentioned, only the functions "FUNCTION {author.organization.sort}" and "FUNCTION {editor.organization.sort}", and then copy the contents of "FUNCTION {presort}" into "FUNCTION {bib.sort.order}". This solved the problem! – Erel Segal-Halevi May 8 '16 at 12:15
• For reference: here is the modified file that works for me: github.com/erelsgl/erelsgl.github.io/blob/master/papers/… – Erel Segal-Halevi May 10 '16 at 5:59

The way references are ordered is controlled by the .bst file. If you want to change the ordering, then you need to modify that file.

Here is how you can modify your elsarticle-num-names.bst file in order to have your references sorted alphabetically. I suggest creating a copy of that file and name it elsarticle-names.bst before modifying it.

First, locate the presort function in that .bst file. It may look like this:

FUNCTION {presort}
{ calc.label
label sortify
"    "
*
seq.num #1 + 'seq.num :=
seq.num  int.to.fix
'sort.label :=
sort.label
*
"    "
*
title field.or.null
sort.format.title
*
#1 entry.max$substring$
'sort.key$:= } Then, replace it with the following: FUNCTION {presort} { calc.label label sortify " " * type$ "book" =
type$"inbook" = or 'author.editor.sort { type$ "proceedings" =
'editor.sort
'author.sort
if$} if$
#1 entry.max$substring$
'sort.label :=
sort.label
*
"    "
*
title field.or.null
sort.format.title
*
#1 entry.max$substring$
'sort.key\$ :=
}

There are also several alternate .bst files provided by Elsevier (with or without alphabetical sorting) in the sample manuscript available here. It should be reminded however that, if you intend to submit an article to a scientific journal, you should use the .bst file provided by the editor for that specific journal without modification. There are indeed strict guidelines that you must comply with regarding formatting of the bibliography.