Chinese (string)

Sort Chinese characters

Sorting in Javascript for Chinese Character. The Chinese Characters are sorted on the radical and number of strokes. This plug-in performs sorting for Chinese characters using the Javascript localeCompare function.

Please note that localeCompare is not implemented in the same way in all browsers, potentially leading to different results (particularly in IE).

Plug-in code

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
    "chinese-string-asc" : function (s1, s2) {
        return s1.localeCompare(s2);

    "chinese-string-desc" : function (s1, s2) {
        return s2.localeCompare(s1);
} );


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: 'chinese-string', targets: 0 }
  } );