0
|
1
|
|
2 $.extend( DataTable.ext.oSort, {
|
|
3 /*
|
|
4 * text sorting
|
|
5 */
|
|
6 "string-pre": function ( a )
|
|
7 {
|
|
8 if ( typeof a != 'string' ) {
|
|
9 a = (a !== null && a.toString) ? a.toString() : '';
|
|
10 }
|
|
11 return a.toLowerCase();
|
|
12 },
|
|
13
|
|
14 "string-asc": function ( x, y )
|
|
15 {
|
|
16 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
|
17 },
|
|
18
|
|
19 "string-desc": function ( x, y )
|
|
20 {
|
|
21 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
|
22 },
|
|
23
|
|
24
|
|
25 /*
|
|
26 * html sorting (ignore html tags)
|
|
27 */
|
|
28 "html-pre": function ( a )
|
|
29 {
|
|
30 return a.replace( /<.*?>/g, "" ).toLowerCase();
|
|
31 },
|
|
32
|
|
33 "html-asc": function ( x, y )
|
|
34 {
|
|
35 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
|
36 },
|
|
37
|
|
38 "html-desc": function ( x, y )
|
|
39 {
|
|
40 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
|
41 },
|
|
42
|
|
43
|
|
44 /*
|
|
45 * date sorting
|
|
46 */
|
|
47 "date-pre": function ( a )
|
|
48 {
|
|
49 var x = Date.parse( a );
|
|
50
|
|
51 if ( isNaN(x) || x==="" )
|
|
52 {
|
|
53 x = Date.parse( "01/01/1970 00:00:00" );
|
|
54 }
|
|
55 return x;
|
|
56 },
|
|
57
|
|
58 "date-asc": function ( x, y )
|
|
59 {
|
|
60 return x - y;
|
|
61 },
|
|
62
|
|
63 "date-desc": function ( x, y )
|
|
64 {
|
|
65 return y - x;
|
|
66 },
|
|
67
|
|
68
|
|
69 /*
|
|
70 * numerical sorting
|
|
71 */
|
|
72 "numeric-pre": function ( a )
|
|
73 {
|
|
74 return (a=="-" || a==="") ? 0 : a*1;
|
|
75 },
|
|
76
|
|
77 "numeric-asc": function ( x, y )
|
|
78 {
|
|
79 return x - y;
|
|
80 },
|
|
81
|
|
82 "numeric-desc": function ( x, y )
|
|
83 {
|
|
84 return y - x;
|
|
85 }
|
|
86 } );
|