Q:

Tablesorter: How to sort by Japanese days?

I use tablesorter, but sorting Japanese days doesn't work properly. 
They should be in the following order:
月、火、水、木、金、土、日
How do I make them sort properly?
And for our Japanese speakers, as this might be searched by a searchengine: tablesorterで曜日を整列する。 (was not allowed in title)

A:

Here's the code (might not be the very best):
$.tablesorter.addParser({ 
    id: 'jpdays',  //ID を設定する
    is: function(s) {   //通常は false を返す様に作るとマニュアルに書いてある
        return false;
    }, 
    format: function(s) { 
            //数字の部分だけ取り出す
            if(s.match("月")){
                s = "1";
            }else if(s.match("火")){
                s = "2";
            }else if(s.match("水")){
                s = "3";
            }else if(s.match("木")){
                s = "4";
            }else if(s.match("金")){
                s = "5";
            }else if(s.match("土")){
                s = "6";
            }else if(s.match("日")){
                s = "7";
            }

            return s;
        }, 
    //文字列として処理する
    type: 'string'
}); 

This should be called on the tablesorter before you call
$("#mytable").tablesorter();
For more information check out the help page: https://mottie.github.io/tablesorter/docs/example-parsers.html

