# biblatex sorting when the same first name is spelled out or an initial

I am trying to sort some citations/bibliography by the following keys:

1. Author name (as formatted by maxnames and uniquenames).
2. Publication year (as formatted by labelyear).

Using some standard options, I can get the formatting almost perfectly:

\RequirePackage{filecontents}
\begin{filecontents*}{papers.bib}
@article{colby_1999,
author={Colby, J and Brown, A and Brown, B},
title={Title},
year={1999},
}

@article{colby_2000,
author={Colby, John and Brown, A and Brown, B},
title={Title},
year={2000},
}

@article{colby_2001,
author={Colby, J and Brown, A and Brown, B},
title={Title},
year={2001},
}

@article{colby_2001_2,
author={Colby, J and Damon, A and Brown, B},
title={Title},
year={2001},
}

@article{colby_2002,
author={Colby, J and Class, A and Brown, B},
title={Title},
year={2002},
}

@article{colby_a_2002,
author={Colby, A and Class, A and Brown, B},
title={Title},
year={2002},
}

author={Adams, J and Class, A and Brown, B},
title={Title},
year={1998},
}

author={Adams, J and Class, A and Brown, B},
title={Title},
year={2002},
}
\end{filecontents*}

\documentclass{article}

\usepackage[style=authoryear-comp, natbib, backend=biber]{biblatex}
\ExecuteBibliographyOptions{
maxnames    = 1,
maxbibnames = 99,
uniquelist  = false,
uniquename  = true,
dashed      = false,
firstinits  = true}

\begin{document}
\printbibliography
\end{document}


The only catch is that I would like the "Colby, John" and all of the "Colby, J" entries to be treated the same for sorting purposes. In other words, I want all of those entries to be compacted into 1 block in the citation, and I want the "Colby, John" entry to be sorted by year within the other "Colby, J"s in the bibliography. Something like this:

-
I asked a similar question awhile back. You need to make use of the shortauthor and sortname fields - they should contain "standardized" versions of the author names. This can be done by manually editing your bib file or using the biber sourcemap option. – Audrey Feb 24 '12 at 21:02
Why not simply writing out the first name on all entries? Or not writing out "John" on that one entry. – Mikael Öhman Feb 24 '12 at 21:13
@MikaelÖhman You could. That was the response I got in my question. But I don't like changing the bibliographic data. I am also very lazy when it comes to editing the bib file. So the sourcemap solution is the one I decided to use. – Audrey Feb 24 '12 at 21:17
@Audrey Thanks for the link! – John Colby Feb 25 '12 at 22:24
@MikaelÖhman Thanks...this is of course the simplest in the short term, but I agree with Audrey that in my case it will be a pain in the long run as I'll need to continually mess with the .bib as I import new articles for different journals that use different name formatting. – John Colby Feb 25 '12 at 22:26

The thing to remember is that Biber can't know that "John Colby" and "J Colby" are the same person purely by syntax (which is all it has to go on ...). The "firstinits" option does not effect sorting as it's common for people to want to sorting to obey full names in the case of identical initials etc.

You have several options:

1. Edit your bibliography source data and make the names which are semantically equivalent, syntactically equivalent so that Biber has the relevant information for sorting.
2. Edit your bibliography source data to add sortname and/or shortauthor fields to change the sorting to what you need, without changing the names.
3. Use the Biber sourcemap option as mentioned in the comments to automatically do either 1. or 2. without changing the source at all.
4. Use the biber 0.9.9 (beta) "sortfirstinits" option which makes the sorting algorithm use only the initials of the first names. An unofficial biblatex 1.7 patched .sty, .def and .pdf doc is here: https://sourceforge.net/projects/biblatex-biber/files/biblatex-test and you will need biber 0.9.9 beta from sourceforge. The new option is in the test biblatex manual. Try it with sortfirstinits = true in your options.

Where possible, I recommend option 1. as it's better to make syntax and semantics coincide when you need to automated systems.

To only consider the first author for sorting, you could do something like this with sourcemap:

<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" map_overwrite="1">
<map>
<map_step map_field_source="AUTHOR" map_match="\AColby," map_final="1"/>
<map_step map_field_set="SORTNAME" map_origfieldval="1"/>
<map_step map_field_source="SORTNAME" map_match="\A(.+?)\s+and" map_replace="\$1"/>
</map>
</maps>
</sourcemap>
</config>

-
Thanks. I will play around with biber to get #3 working for my specific case. It would be nice, though, if there was a mode that would automatically use the more flexible firstinits and uniquename logic that is already coded in there. Like in this example, my desired sort names (Adams, ColbyJ, ColbyA) are already there perfectly in the citation. Is there any way to simply assign these strings to sortname? – John Colby Feb 25 '12 at 22:23
Actually, I think you're right, this should have a separate option called "sortfirstinits" so you can decouple this from firstinits and choose to have sorting only look at first name initials. See update in answer. – PLK Feb 26 '12 at 19:50
Terrific, thanks! Now, using the sourcemap syntax, I see how I can match names in a name list based on regexps and set those entries to NULL, but is there a way to just index directly? For sorting purposes, I'd like to just keep the first author and delete the rest. – John Colby Feb 27 '12 at 2:33
Should be possible with sourcemap, see edit in answer – PLK Feb 27 '12 at 6:34