| 4 |
lars |
1 |
/**
|
|
|
2 |
* Sorting in Javascript for Chinese Character. The Chinese Characters are
|
|
|
3 |
* sorted on the radical and number of strokes. This plug-in performs sorting
|
|
|
4 |
* for Chinese characters using the Javascript [localeCompare](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/localeCompare)
|
|
|
5 |
* function.
|
|
|
6 |
*
|
|
|
7 |
* Please note that `localeCompare` is not implemented in the same way in all
|
|
|
8 |
* browsers, potentially leading to different results (particularly in IE).
|
|
|
9 |
*
|
|
|
10 |
* @name Chinese (string)
|
|
|
11 |
* @summary Sort Chinese characters
|
|
|
12 |
* @author [Patrik Lindström](http://www.lcube.se/sorting-chinese-characters-in-javascript/)
|
|
|
13 |
*
|
|
|
14 |
* @example
|
|
|
15 |
* $('#example').dataTable( {
|
|
|
16 |
* columnDefs: [
|
|
|
17 |
* { type: 'chinese-string', targets: 0 }
|
|
|
18 |
* ]
|
|
|
19 |
* } );
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
|
|
|
23 |
"chinese-string-asc" : function (s1, s2) {
|
|
|
24 |
return s1.localeCompare(s2);
|
|
|
25 |
},
|
|
|
26 |
|
|
|
27 |
"chinese-string-desc" : function (s1, s2) {
|
|
|
28 |
return s2.localeCompare(s1);
|
|
|
29 |
}
|
|
|
30 |
} );
|