SOURCE

function regionSort(d1, d2) {

    var year_wcl_1 = d1['year_wcl'];
    var year_wcl_2 = d2['year_wcl'];

    year_wcl_1 = year_wcl_1 == '-' ? -Infinity : Number(year_wcl_1);
    year_wcl_2 = year_wcl_2 == '-' ? -Infinity : Number(year_wcl_2);

    return year_wcl_2 - year_wcl_1;
}

function wclSortAsc(d1, d2) {

    var year_wcl_1 = d1['year_wcl'];
    var year_wcl_2 = d2['year_wcl'];

    year_wcl_1 = year_wcl_1 == '-' ? -Infinity : Number(year_wcl_1);
    year_wcl_2 = year_wcl_2 == '-' ? -Infinity : Number(year_wcl_2);

    return year_wcl_1 - year_wcl_2;
}

function processData(columnStr, dataStr, paramStr) {
    var datas = JSON.parse(dataStr);
    var queryParams = JSON.parse(paramStr);
    var params = JSON.stringify(queryParams['params']);
    params = JSON.parse(params);
    var orders = JSON.stringify(queryParams['orders']);

    var order;
    if (orders != undefined) {
        orders = JSON.parse(orders);
        order = orders.length > 0 ? JSON.parse(JSON.stringify(orders[0])) : undefined;
    }

    if (order === undefined || (order['direction'] != 'asc' && order['direction'] != 'desc')) {
        datas.sort(regionSort);
    }

    if (order != undefined) {
        var column = order['column'];
        if (column == "`year_wcl`" && order['direction'] == 'asc') {
            datas.sort(wclSortAsc);
        }

        if (column == "`year_wcl`" && order['direction'] == 'desc') {
            datas.sort(regionSort);
        }
    }

    return JSON.stringify(datas);
}
console 命令行工具 X clear

                    
>
console