From ef57f0dc2c7d4da2494f6e9da3f86ee75dbbd062 Mon Sep 17 00:00:00 2001 From: Patrik Lindstrom Date: Sat, 21 Jul 2012 16:25:06 +0200 Subject: [PATCH] Added Chinese-string sorting plugin chinese-string-asc and chinese-string-desc plugin added. Uses localeCompare to sort chinese character on radical and stroke order. See http://www.lcube.se/sorting-chinese-characters-in-javascript/ for more explainations. Not sure about anchor name and the pre method. --- sorting/chinese-string.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sorting/chinese-string.js diff --git a/sorting/chinese-string.js b/sorting/chinese-string.js new file mode 100644 index 0000000..d7562f2 --- /dev/null +++ b/sorting/chinese-string.js @@ -0,0 +1,19 @@ +/** + * 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. + * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/localeCompare + * Please note about localcompare http://www.datatables.net/forums/discussion/9700/sorting-non-ascii-characters-and-data-content-html-tag-sorting/p1 + * @name Chinese-String + * @anchor chinese-string + * @author Patrik Lindström + */ + + 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); + } +} + ); \ No newline at end of file