# Custom Sorting Order for the Bibliography with biblatex according to Sanskrit Alphabet

I want to add a bibliography of primary sources to an article, and sort its entries alphabetically according to Sanskrit alphabet, using IAST and utf-8, a, ā, i, ī, u, ū and so on, how can I tell biblatex / biber to do that? I guess I have to define that alphabet myself, how is that done?

A minimum working example:

\documentclass{article}
\usepackage{fontspec}
\usepackage{filecontents}
\usepackage[style=authoryear-ibid,backend=biber,sorting=anyt]{biblatex}

\begin{filecontents*}{mwe.bib}

@misc {Hevajratantra,
title = {Hevajratantra},
note = {something},
}

@book {Mṛgendratantra,
title = {Mṛgendratantra},
note = {something else},
}

\end{filecontents*}

\begin{document}

\nocite{*}
\printbibliography{}

\end{document}


As expected the bibliography first lists the Hevajratantra, then the Mṛgendratantra, as per the Latin alphabetical order. In the Sanskrit alphabet though M is before H, the Sanskrit alphabet being completely different from the Latin alphabet. I could deal with this problem manually by, for example, adding a sortkey field to each bibliography entry, but I assume for most bigger languages one can tell biblatex / biber e.g. via polyglossia how to do the sorting according to the respective language. I wonder what would be the way to get it done automatically for transliterated Sanskrit?

After some more searching it seems that I'd need to build a table for the Unicode Collation Algorithm, following the data format of this one, https://github.com/plk/biber/blob/master/data/latinkeys.txt, which I'd then need to feed to biber. Doesn't look too complex, I'll try to find a temporary solution.

• Welcome to TeX.SX! Please add a complete minimal working example (MWE) to show your problem and to ease the work of the users willing to help. – Pier Paolo Dec 16 '14 at 11:08
• Thank you! I edited my question, adding a minimum working example. – muk.li Dec 16 '14 at 13:26
• Biber support all CLDR tailored locales supported by the Unicode::Collate module (search.cpan.org/~sadahiro/Unicode-Collate-1.08/Collate/…). By the look of the Sanskrit tailoring, it doesn't do enough of what you need? – PLK Dec 17 '14 at 14:08
• Thank you @PLK! The Sanskrit tailoring supported there is dealing with the code range 0900 - 097F for the Devanagari script. What I need though is a tailoring (or maybe rather a new locale?) for transliterated Sanskrit in Roman Script, according to IAST. For that purpose I tried to modify the latinkeys.txt file, but didn't get biber to use it. I guess I was on the wrong track, looking at the tailorings you now point me to. Any help is appreciated. – muk.li Dec 18 '14 at 16:33
• Is this userguide.icu-project.org/collation/customization the route I should take? – muk.li Dec 18 '14 at 17:02

Starting from version 3.4 biblatex supports transliteration with different sorting

\DeclareSortTranslit{
\translit[settitles]{iast}{devanagari}
}


This should gives you the correct Sanskrit sorting order

\documentclass{article}
\usepackage{fontspec}
\usepackage{filecontents}
\usepackage[style=authoryear-ibid,backend=biber,sorting=anyt]{biblatex}

\begin{filecontents*}{\jobname.bib}
@misc {Hevajratantra,
title = {Hevajratantra},
note = {something},
}

@book {Mṛgendratantra,
title = {Mṛgendratantra},
note = {something else},
}
\end{filecontents*}

\DeclareSortTranslit{
\translit[settitles]{iast}{devanagari}
}