搬砖 - js 排序es6

function SortCharVal(pColumn, asc) 
{
    vCoverageListResponse = vCoverageListResponse.sort(function(vObj1, vObj2) {
        if (asc) 
        {
            return (vObj1[pColumn] > vObj2[pColumn]) ? 1 : ((vObj1[pColumn] < vObj2[pColumn]) ? -1 : 0);
        } 
        else 
        {
            return (vObj2[pColumn] > vObj1[pColumn]) ? 1 : ((vObj2[pColumn] < vObj1[pColumn]) ? -1 : 0);
        }
    });
}

 

posted @ 2020-12-14 02:05  雾中的-松  阅读(245)  评论(0编辑  收藏  举报