mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-20 18:54:15 +01:00
New: Use localeCompare to do string comparison, allowing much better internationlisation support for sorting strings in DataTables
This commit is contained in:
parent
66a2e3d659
commit
f535031e41
12
media/js/jquery.dataTables.js
vendored
12
media/js/jquery.dataTables.js
vendored
@ -10199,17 +10199,17 @@
|
||||
"string-pre": function ( a )
|
||||
{
|
||||
if ( typeof a != 'string' ) { a = ''; }
|
||||
return a.toLowerCase();
|
||||
return a.toLocaleLowerCase();
|
||||
},
|
||||
|
||||
"string-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
return x.localeCompare(y);
|
||||
},
|
||||
|
||||
"string-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
return y.localeCompare(x);
|
||||
},
|
||||
|
||||
|
||||
@ -10218,17 +10218,17 @@
|
||||
*/
|
||||
"html-pre": function ( a )
|
||||
{
|
||||
return a.replace( /<.*?>/g, "" ).toLowerCase();
|
||||
return a.replace( /<.*?>/g, "" ).toLocaleLowerCase();
|
||||
},
|
||||
|
||||
"html-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
return x.localeCompare(y);
|
||||
},
|
||||
|
||||
"html-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
return y.localeCompare(x);
|
||||
},
|
||||
|
||||
|
||||
|
@ -6,17 +6,17 @@ $.extend( DataTable.ext.oSort, {
|
||||
"string-pre": function ( a )
|
||||
{
|
||||
if ( typeof a != 'string' ) { a = ''; }
|
||||
return a.toLowerCase();
|
||||
return a.toLocaleLowerCase();
|
||||
},
|
||||
|
||||
"string-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
return x.localeCompare(y);
|
||||
},
|
||||
|
||||
"string-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
return y.localeCompare(x);
|
||||
},
|
||||
|
||||
|
||||
@ -25,17 +25,17 @@ $.extend( DataTable.ext.oSort, {
|
||||
*/
|
||||
"html-pre": function ( a )
|
||||
{
|
||||
return a.replace( /<.*?>/g, "" ).toLowerCase();
|
||||
return a.replace( /<.*?>/g, "" ).toLocaleLowerCase();
|
||||
},
|
||||
|
||||
"html-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
return x.localeCompare(y);
|
||||
},
|
||||
|
||||
"html-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
return y.localeCompare(x);
|
||||
},
|
||||
|
||||
|
||||
|
@ -38,11 +38,10 @@
|
||||
//}
|
||||
|
||||
oTable.fnSort( [[ 1, 'asc' ]] );
|
||||
oTable.fnFilter(1);
|
||||
oTable.fnSort( [[ 1, 'asc' ]] );
|
||||
//oTable.fnSort( [[ 2, 'asc' ]] );
|
||||
//oTable.fnSort( [[ 1, 'asc' ]] );
|
||||
//oTable.fnSort( [[ 2, 'asc' ]] );
|
||||
oTable.fnSort( [[ 2, 'asc' ]] );
|
||||
oTable.fnSort( [[ 1, 'asc' ]] );
|
||||
oTable.fnSort( [[ 2, 'asc' ]] );
|
||||
|
||||
var iEnd = new Date().getTime();
|
||||
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+" mS";
|
||||
|
Loading…
x
Reference in New Issue
Block a user