const sortTabularGridColumn = (e, rowsArrayData, dateType = "string", objectProperty) => {
    const { columnId, sortDirection } = e.detail;
    // date or dateString
    if (dateType === "date" || dateType === "dateString") {
        return rowsArrayData.sort((a, b) => {
            const columnA = a[columnId];
            const columnB = b[columnId];
            if (dateType === "dateString") {
                a = new Date(columnA);
                b = new Date(columnB);
            }
            if (columnA.getTime() < columnB.getTime()) {
                return sortDirection === "asc" ? -1 : 1;
            }
            if (columnA.getTime() > columnB.getTime()) {
                return sortDirection === "asc" ? 1 : -1;
            }
            return 0;
        });
    }
    // string or objectProperty
    return rowsArrayData.sort((a, b) => {
        const columnA = objectProperty
            ? a[columnId][objectProperty]
            : a[columnId];
        const columnB = objectProperty
            ? b[columnId][objectProperty]
            : b[columnId];
        if (columnA < columnB) {
            return sortDirection === "asc" ? -1 : 1;
        }
        if (columnA > columnB) {
            return sortDirection === "asc" ? 1 : -1;
        }
        return 0;
    });
};

export { sortTabularGridColumn as s };

//# sourceMappingURL=tabular-grid-column-sort-1d503b27.js.map