Sorting of the bibliography requires that you have an external database of entries rather than a hand built list. In your case your external file mybib.bib
could be:
@Article{art,
author = {Art, John},
title = {John's Article},
journal = {J. Jour.},
year = 2006,
volume = 7,
pages = {12-45}
}
@Book{fart,
author = {Fart, Peter},
title = {Travelling at speed},
publisher = {P. Press},
year = 2009,
address = {Sometown}
}
To use this in your document there are two approaches: (1) traditional bibtex
; (2) modern biblatex
.
Bibtex approach
Choose a style for the bibliography via \bibliographystyle
. Choose the database file and print the bibliography via \bibliography{mybib}
. As you seem to want your authors listed as Lastname, Firstname
then one choice is the apa
style, which requires the natbib
package; pass the option numbers
to this package to get numerical citations.
\documentclass{article}
\usepackage[numbers]{natbib}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat~\cite{fart}. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum~\cite{art}.
\bibliographystyle{apa}
\bibliography{mybib}
\end{document}
Compile as
pdflatex myfile
bibtex myfile
pdflatex myfile
to get

Read more at bibtex on CTAN
Biblatex approach
Load the package biblatex
, with style=numeric
for numerical citations. To get Lastname, Firstname in the bibilography use the command \DeclareNameAlias{default}{last-first}
. Point to your database via \addbibresource{mybib.bib}
. Put \printbibliography
at the place in you file you want the bibliography to appear.
\documentclass{article}
\usepackage[style=numeric]{biblatex}
\addbibresource{mybib.bib}
\DeclareNameAlias{default}{last-first}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat~\cite{fart}. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum~\cite{art}.
\printbibliography
\end{document}
Compile with
pdflatex myfile
biber myfile
pdflatex myfile
to get

Read more at Guidelines for customizing biblatex styles and in the biblatex
manual combined with the bitex reference above.
thebibliography
environment, you are responsible for typing the references as you like.