import React from "react"; export default { sort(col, itemType: string, defaultSort?) { let colName = col["dataIndex"]; // if (itemType == "decimal" || itemType == "int" || itemType == "float" || itemType == "double") { //排序b // col["sorter"] = (a, b) => a[colName] - b[colName]; // } else if (itemType == "text" || itemType == "textarea" || itemType == "date" || itemType == "datetime") { // col["sorter"] = (a, b) => a[colName] ? a[colName].localeCompare(b[colName], 'zh-CN') : -1; // } else { // col["sorter"] = (a, b) => { //排序 // if (a[colName] && b[colName] && a[colName].localeCompare) { // return a[colName] ? a[colName].localeCompare(b[colName], 'zh-CN') : -1; // } else { // return 1; // } // } // } col["sorter"] = true; if (defaultSort) { col["sortOrder"] = defaultSort; } col["showSorterTooltip"] = false; }, };