<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% This file is embedded in datatool-user.pdf version 3.2 2025-03-14
% Example 12 Icelandic Sorting and Letter Groups
% Label: "ex:icelandiclettergroup"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{datatool-base}
\ExplSyntaxOn 

\newcommand{\DTLisLocaleHandler}[1]{
 \regex_replace_case_all:nN
 {
  { Ã } { A\cL\x{7f} }
    { Ã¡ } { a\cL\x{7f} }
    { Ã } { D\cL\x{7f} }
    { Ã° } { d\cL\x{7f} }
    { Ã‰ } { E\cL\x{7f} }
    { Ã© } { e\cL\x{7f} }
    { Ã } { I\cL\x{7f} }
    { Ã­ } { i\cL\x{7f} }
    { Ã“ } { O\cL\x{7f} }
    { Ã³ } { o\cL\x{7f} }
    { Ãš } { U\cL\x{7f} }
    { Ãº } { u\cL\x{7f} }
    { Ã } { Y\cL\x{7f} }
    { Ã½ } { y\cL\x{7f} }
    { Ãž } { \cL\x{5b} }
    { Ã¾ } { \cL\x{7b} }
    { Ã† } { \cL\x{5c} }
    { Ã¦ } { \cL\x{7c} }
    { Ã– } { \cL\x{5d} }
    { Ã¶ } { \cL\x{7d} }
    { ([[:punct:]]+) } { \cO"\1 }
    }
 #1
} 

\newcommand{\DTLisLocaleGetInitialLetter}[2]{
 \tl_set:Nn #2 { #1 }
 \regex_replace_case_all:nN
 {
  { A\cL\x{7f} } { Ã } { a\cL\x{7f} } { Ã¡ }
  { D\cL\x{7f} } { Ã } { d\cL\x{7f} } { Ã° }
  { E\cL\x{7f} } { Ã‰ } { e\cL\x{7f} } { Ã© }
  { I\cL\x{7f} } { Ã } { i\cL\x{7f} } { Ã­ }
  { O\cL\x{7f} } { Ã“ } { o\cL\x{7f} } { Ã³ }
  { U\cL\x{7f} } { Ãš } { u\cL\x{7f} } { Ãº }
  { Y\cL\x{7f} } { Ã } { y\cL\x{7f} } { Ã½ }
  { \cL\x{5b} } { Ãž } { \cL\x{7b} } { Ã¾ }
  { \cL\x{5c} } { Ã† } { \cL\x{7c} } { Ã¦ }
  { \cL\x{5d} } { Ã– } { \cL\x{7d} } { Ã¶ }
  } #2
 \exp_args:No \datatool_get_first_letter:nN { #2 } #2
} 

\ExplSyntaxOff 

\let\DTLCurrentLocaleWordHandler\DTLisLocaleHandler \let\DTLCurrentLocaleGetInitialLetter\DTLisLocaleGetInitialLetter 

\newcommand{\mylist}{bÃ³kstafinn, vera, eÃ°a, 
 Ã©g, bÃ½sna, Ã¾Ãº, vakna, epli, bragÃ°s, aldar, baÃ°, bolli, Ã½mist, af, 
 Ã³Ã¡reiÃ°anleg, bÃ¦r, dalur, Ã¶r, Ã¾orn, Ã¾au, oktÃ³ber, esja, Ã¶ngull, dÃ¦mi, aÃ°, yfir, 
 Ã¶Ã°rum, orÃ°, detta, Ã¡hrif, yngri, Ã³vinur, Ã¦tlaÃ°} 
\begin{document}
\DTLsortwordlist{\mylist}{\DTLsortletterhandler}
\renewcommand{\DTLlistformatitem}[1]{#1 (\DTLsortedletter{#1})}
Sorted list: \DTLformatlist{\mylist}. 
\end{document}
</pre></body></html>