I am working on a table that will contain data, and what I should be able to do is sort the data by using the columns, so by clicking the columns it will order the data alphabetically and so on. To achieve this need I came across tablesorter jquery library, which works absolutely fine when sorting English alphabetic characters.
However the problem I am encountering is that I will have multiple tables, where each table will contain data only for a specific country on a specific language from a range of 60 countries, so I should be fine with English/Latin Characters, but I am encountering problem when dealing with Russian, Chinese, Japanese and other languages, does anyone know a quick work around that may help me in this occasion.
Any comments are welcome.
If you are using my 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 array sort.
$(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
}
});
});
For languages like Russian, Chinese & Japanese, you'll need to modify the Array.AlphanumericSortOrder
variable for that language.