Sort with the prefixed word The removed, if present

Often a list of data which has titles in it (books, albums etc) will have the word "the" at the start of some individual titles, which you don't want to include in your sorting order. This plug-in will strip the word "the" from the start of a string and sort on what is left.

Plug-in code

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
    "anti-the-pre": function ( a ) {
        return a.replace(/^the /i, "");

    "anti-the-asc": function ( a, b ) {
        return ((a < b) ? -1 : ((a > b) ? 1 : 0));

    "anti-the-desc": function ( a, b ) {
        return ((a < b) ? 1 : ((a > b) ? -1 : 0));
} );


This plug-in is available on the DataTables CDN:


Note that if you are using multiple plug-ins, it is beneficial in terms of performance to combine the plug-ins into a single file and host it on your own server, rather than making multiple requests to the DataTables CDN.

Version control

If you have any ideas for how this plug-in can be improved, or spot anything that is in error, it is available on GitHub and pull requests are very welcome!


$('#example').dataTable( {
     columnDefs: [
       { type: 'anti-the', targets: 0 }
  } );