% This file is embedded in datatool-user.pdf version 3.4.1 2025-04-25
% Example 62 Sort Word Hook (Roman Numerals)
% Label: "ex:sortwordhook"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{datatool-base}
\newcommand{\mylist}{John XVI,John VI, John XIX, John IX, John IV,John VII, John V} 
\begin{document}
\DTLsortwordlist{\mylist}{\DTLsortwordhandler}
\DTLformatlist{\mylist}. 

\newcommand{\Ord}[1]{\MakeUppercase{\romannumeral #1}}
\dtlSortWordCommands{\renewcommand\Ord[1]{\two@digits{#1}}}
\renewcommand{\mylist}{John \Ord{16},John \Ord{6},
John \Ord{19}, John \Ord{9}, John \Ord{4},John \Ord{7},
John \Ord{5}}
\DTLsortwordlist{\mylist}{\DTLsortwordhandler}
\DTLformatlist{\mylist}. 
\end{document}
