# Strange problem with BibTeX sorting

I know that Umlaute have to be avoided in BibTeX and I am using {\"a}, in fact I use BibDesk and it produces the correct LaTeX code. The sorting works for small characters, but I have one name starting with Ö. Although I use {{\.I}nci {\"O}zkarag{\"o}z}, the item is sorted after all authors with O. What can I do?

Apart from this Ø should be sorted last, but is sorted in the middle of O.

Edit: I want to have the German ordering, that is, Ö should be sorted as Oe not as O. The Ø-sorting is Danish.

-
Where do you think {\"O}zkarag{\"o}z should be sorted (the Ö is followed by z)? Also, don't use braces around single authors, other than those needed for the author field. To get {\O} last, try author = {\noopsort{Ozzz}{\O}stersund, A.}. – mafp Feb 6 '13 at 17:00
Which national alphabetical sorting convention do you need to adhere to? Separately, do you load babel? If so, with which language, or languages? It would be helpful if you posted a full MWE (minimum working example) that generates the problem behavior you're trying to fix, rather than just a code snippet. – Mico Feb 6 '13 at 17:09
I tried with author named "Ottor", "{\"O}zkarag{\"o}z" and "Ozzor" and the same is the alphabetical order. – egreg Feb 6 '13 at 17:10

When BibTex sees a sequence like {\"O} or {\O}, for sorting purposes these special characters are reduced to O. The task is therefore to trick BibTex into thinking that the first example looks like Oe, while the second should look like ZZZZZO. For that, we introduce two macros, \donothing and \printsecond.

{\donothing{text}} will show nothing in the final bibliography, but "text" will be taken into account for sorting, so {\"O}{\donothing{e}} will print as "Ö", and sorted as "Oe".

{\printsecond{foo}{bar}} will print "bar", and be sorted as "foobar".

Example:

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents}{SM.bib}
@misc{a, author={{\printsecond{ZZZZZ}{\O}}stersund, A}, title={a}, year=1000}
@misc{b, author={{\"O\donothing{e}}zkarag{\"o}z, {\.I}nci}, title={b}, year=1001}
@misc{c, author={Oezl, A}, title={c}, year=1002}
@misc{d, author={Oezj, A}, title={d}, year=1003}
@misc{e, author={Ofa, A}, title={e}, year=1004}
@misc{f, author={Zzz, A}, title={f}, year=1005}
\end{filecontents}

\begin{document}
\nocite{*}

\providecommand*{\donothing}[1]{}
\providecommand*{\printsecond}[2]{#2}

\bibliographystyle{plain} % works
% \bibliographystyle{alpha} % works ...
% \bibliographystyle{apalike} % works
\bibliography{SM}
\end{document}


Using the plain style, the sorting keys for these entries are: zzzzzostersund1000, oezkaragoz1001, oezl1002, oezj1003, ofa1004, zzz1005, which gives the correct order:

Using the alpha style, the entries are sorted by label, which consists of three letters of the author name, and the last two digits of the year for single author references. The sorting keys are therefore: zzzzzost1000, oezk1001, oez1002, oez1003, ofa1004, zzz1005. You can see here that the special characters are treated as one character by BibTeX, even when several plain characters are extracted when generating the sorting key. The output is therefore:

and indeed "Oez03" < "Özk01", as oez1003 < oezk1001, since 1 < k. If you would like it the other way round, the Özk01 has to be shortened to Öz01, which can be achieved in the database by changing the second entry to

@misc{b, author={{\"O}{\donothing{e}}zkarag{\"o}z, {\.I}nci}, title={b}, year=1001}


(Note how the "invisible" e is now a special character of its own, and counted as such, as it jumped out of the first special character.)

-
OK. This solves the problem at hand, but there must be a better way. With this way I would have to replace all Umlaute by ...\donothing. Right now I have Lüdeling, Luger, Lühr instead of Lüdeling, Lühr, Luger. Putting the \donothing in BibTeX basically ruins the database functions of BibDesk (search and so on). – Stefan Müller Feb 19 '13 at 19:40
@StefanMüller I'm afraid the only "better way" is switching to biblatex+biber. – mafp Feb 19 '13 at 19:48
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6315354704856873, "perplexity": 4139.257277992658}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-07/segments/1454701157212.22/warc/CC-MAIN-20160205193917-00234-ip-10-236-182-209.ec2.internal.warc.gz"}