多种语言的 TableSort
TableSort for multiple languages
我正在处理一个包含数据的 table,我应该能够做的是使用列对数据进行排序,因此通过单击列,它将按字母顺序对数据进行排序等等上。为了实现这个需求,我遇到了 tablesorter jquery 库,它在对英文字母字符进行排序时工作得非常好。
但是我遇到的问题是我将有多个 table,其中每个 table 将仅包含来自 60 个国家/地区的特定语言的特定国家/地区的数据,所以我应该可以使用 English/Latin 个字符,但是我在处理俄语、中文、日语和其他语言时遇到了问题,有谁知道可以在这种情况下帮助我的快速解决方法。
欢迎任何评论。
如果您使用我的 fork of tablesorter, you can set the textSorter
option to use alternative sorting algorithms. Specifically, here is a demo that sorts the Icelandic alphabet using the Sugar 数组排序。
$(function() {
// define sugar.js Icelandic sort order
Array.AlphanumericSortOrder = 'AaÁáBbCcDdÐðEeÉéĘęFfGgHhIiÍíJjKkLlMmNnOoÓóPpQqRrSsTtUuÚúVvWwXxYyÝýZzÞþÆæÖö';
Array.AlphanumericSortIgnoreCase = true;
// see https://github.com/andrewplummer/Sugar/issues/382#issuecomment-41526957
Array.AlphanumericSortEquivalents = {};
$("table").tablesorter({
theme : 'blue',
ignoreCase : false,
textSorter : {
1 : Array.AlphanumericSort, // alphanumeric sort from sugar
}
});
});
对于俄语、中文和日语等语言,您需要修改该语言的 Array.AlphanumericSortOrder
变量。
我正在处理一个包含数据的 table,我应该能够做的是使用列对数据进行排序,因此通过单击列,它将按字母顺序对数据进行排序等等上。为了实现这个需求,我遇到了 tablesorter jquery 库,它在对英文字母字符进行排序时工作得非常好。
但是我遇到的问题是我将有多个 table,其中每个 table 将仅包含来自 60 个国家/地区的特定语言的特定国家/地区的数据,所以我应该可以使用 English/Latin 个字符,但是我在处理俄语、中文、日语和其他语言时遇到了问题,有谁知道可以在这种情况下帮助我的快速解决方法。
欢迎任何评论。
如果您使用我的 fork of tablesorter, you can set the textSorter
option to use alternative sorting algorithms. Specifically, here is a demo that sorts the Icelandic alphabet using the Sugar 数组排序。
$(function() {
// define sugar.js Icelandic sort order
Array.AlphanumericSortOrder = 'AaÁáBbCcDdÐðEeÉéĘęFfGgHhIiÍíJjKkLlMmNnOoÓóPpQqRrSsTtUuÚúVvWwXxYyÝýZzÞþÆæÖö';
Array.AlphanumericSortIgnoreCase = true;
// see https://github.com/andrewplummer/Sugar/issues/382#issuecomment-41526957
Array.AlphanumericSortEquivalents = {};
$("table").tablesorter({
theme : 'blue',
ignoreCase : false,
textSorter : {
1 : Array.AlphanumericSort, // alphanumeric sort from sugar
}
});
});
对于俄语、中文和日语等语言,您需要修改该语言的 Array.AlphanumericSortOrder
变量。