﻿// add parser through the tablesorter addParser method 
$.tablesorter.addParser({
    // set a unique id 
    id: "volume",
    is: function (s) {
        // return false so this parser is not auto detected 
        return false;
    },
    format: function (s) {
        // format your data for normalization 
        return s.replace(/\.|€/g, '').trim();
    },
    // set type, either numeric or text 
    type: 'numeric'
});

$.tablesorter.addParser({
    // set a unique id 
    id: "percentage",
    is: function (s) {
        // return false so this parser is not auto detected 
        return false;
    },
    format: function (s) {
        // format your data for normalization 
        return (s == null || s === '') ? "-9999" : s.replace(/%/, '').trim();
    },
    // set type, either numeric or text 
    type: 'numeric'
});

$.tablesorter.addParser({
    id: "textmetadata",
    is: function (s) {
        return false;
    },
    format: function (s, table, cell) {
        var c = table.config, p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName;
        return $(cell).metadata()[p];
    },
    type: "text"
});
