DataTables localeCompare 排序,无法正常工作

DataTables localeCompare sorting, can't get it to work

我不是程序员,但我可以将一些代码放在一起使其工作。我在这个问题上苦苦挣扎了几个小时。我在 DataTables jQuery 插件中对 non-ascii 个字符进行排序时遇到问题。在 DataTables 网站上找到的代码应该可以正常工作。但事实并非如此。如果能帮我调试,我将不胜感激。我把这段代码放在 header:

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

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

这就是我 运行 表的方式:

$(document).ready( function () {
$('#myTable').DataTable( {
      "autoWidth": false,
      "columns": [
null,
null,
{ "orderable": false },
{ "orderable": false }
  ],
columnDefs: [
{ type: 'polish-string', targets: 1 }
  ],
});
});

脚本在默认排序下运行良好。问题是它不适用于此排序插件。

我在 WordPress 中使用数据表。

Chrome 给我这个:"Uncaught TypeError: Cannot read property 'oSort' of undefined"。

FireFox 给我这个:"TypeError: jQuery.fn.dataTableExt is undefined"。

请帮我调试这个。谢谢。

DataTables 脚本在页脚中。它应该首先加载。

td 中的 href 标签乱七八糟。删除 href 有帮助。感谢提示。