• This parser (added New v2.17.3) will convert roman numerals into their decimal equivalent so the table column can be sorted correctly.
  • There are actually 3 separate parsers included with this script.
    • They are very similar, but were written to cover different use cases.
    • Refer to each in their separate sections below.
  • This demo includes the stored roman numeral values within the table cells, toggle the view using the button directly above the table.

Demo

parsed values within the column
Pure Roman Numerals
Ignore Non-Roman Numerals
Extract Roman Numerals
Short
Long
Ignore last (1) character *
Ignore regex (/^(\w+\s)/)
Extract
I MDLXXXV iiia Mark I 2000 XXVII Sydney
MXI MDCLXVI iiib Mark IV 2012 XXX London
XII MMDCCCLVIII ia Mark V 2020 XXXII Tokyo
CXI MMCCI va Mark VII 2004 XXVIII Athens
XXI MDCCCXL vi b Mk III 1980 XXII Moscow
XIII MMMCXXIX iva Mod X 1972 XX Munich
V DLXXVII via Mod IV 2016 XXXI Rio de Janeiro
X MDCLXV xia Mk VIII 1996 XXVI Atlanta
XI MDXVIII xiiz Mod XII 1976 XXI Montreal
CLXI MDCCCLX xd Mk 0 1992 XXV Barcelona
C CCCXCI iiic Mk VI 1988 XXIV Seoul
LV MLXXX xxf Mk II 1984 XXIII Los Angeles
IX DCCLVII lig Mod L 2008 XXIX Beijing
* Ignoring the last letter (set number to ignore in roman_ignore option array; notice that "vi b" sorts before "via" - spaces do matter!)

Page Header

<!-- blue theme stylesheet with additional css styles added in v2.0.17 -->
<link rel="stylesheet" href="../css/theme.blue.css">
<!-- tablesorter plugin; requires jQuery -->
<script src="../js/jquery.tablesorter.js"></script>

<!-- load roman numeral parser -->
<script src="../js/parsers/parser-roman.js"></script>

Javascript

$(function() {

$("table").tablesorter({
theme: 'blue',
widgets: ['zebra'],

// roman numeral parser option
// ===========================
// column 0 & 1 are set to zero as placeholders
// column 2: ignore last character (1) - for Roman "roman-ignore" numeral parser
// column 3: ignore characters that match the set regex (beginning of the string to first space)
roman_ignore: [ 0, 0, 1, /^(\w+\s)/ ]

});

});

HTML

<table>
<thead>
<tr>
<th class="sorter-false" colspan="2">Pure Roman Numerals</th>
<th class="sorter-false" colspan="2">Ignore Non-Roman Numerals</th>
<th class="sorter-false">Extract Roman Numerals</th>
</tr>
<tr>
<th class="sorter-roman">Short</th>
<th class="sorter-roman">Long</th>
<th class="sorter-roman-ignore">Ignore last (1) character *</th>
<th class="sorter-roman-ignore">Ignore regex (/^(\w+\s)/)</th>
<th class="sorter-roman-extract">Extract</th>
</tr>
</thead>
<tbody>
<tr><td>I</td><td>MDLXXXV</td><td>iiia</td><td>Mark I</td><td>2000 XXVII Sydney</td></tr>
<tr><td>MXI</td><td>MDCLXVI</td><td>iiib</td><td>Mark IV</td><td>2012 XXX London</td></tr>
<tr><td>XII</td><td>MMDCCCLVIII</td><td>ia</td><td>Mark V</td><td>2020 XXXII Tokyo</td></tr>
<tr><td>CXI</td><td>MMCCI</td><td>va</td><td>Mark VII</td><td>2004 XXVIII Athens</td></tr>
<tr><td>XXI</td><td>MDCCCXL</td><td>vi b</td><td>Mk III</td><td>1980 XXII Moscow</td></tr>
<tr><td>XIII</td><td>MMMCXXIX</td><td>iva</td><td>Mod X</td><td>1972 XX Munich</td></tr>
<tr><td>V</td><td>DLXXVII</td><td>via</td><td>Mod IV</td><td>2016 XXXI Rio de Janeiro</td></tr>
<tr><td>X</td><td>MDCLXV</td><td>xia</td><td>Mk VIII</td><td>1996 XXVI Atlanta</td></tr>
<tr><td>XI</td><td>MDXVIII</td><td>xiiz</td><td>Mod XII</td><td>1976 XXI Montreal</td></tr>
<tr><td>CLXI</td><td>MDCCCLX</td><td>xd</td><td>Mk 0</td><td>1992 XXV Barcelona</td></tr>
<tr><td>C</td><td>CCCXCI</td><td>iiic</td><td>Mk VI</td><td>1988 XXIV Seoul</td></tr>
<tr><td>LV</td><td>MLXXX</td><td>xxf</td><td>Mk II</td><td>1984 XXIII Los Angeles</td></tr>
<tr><td>IX</td><td>DCCLVII</td><td>lig</td><td>Mod L</td><td>2008 XXIX Beijing</td></tr>
</tbody>
</table>