export function descendingComparator(a, b, orderBy, lastOrder) {
    if (getValue(b, orderBy) < getValue(a, orderBy)) {
        return -1;
    }
    if (getValue(b, orderBy) > getValue(a, orderBy)) {
        return 1;
    }
    if (lastOrder && orderBy !== lastOrder) {
        if (getValue(b, lastOrder) < getValue(a, lastOrder)) {
            return 1;
        }
        if (getValue(b, lastOrder) > getValue(a, lastOrder)) {
            return -1;
        }
    }
    return 0;
}

function getValue(obj, orderBy) {
    if (!orderBy) {
        return obj;
    }
    const split = orderBy.split(".")
    let res = obj[split[0]];
    for (let i = 1; i < split.length; i++) {
        res = res[split[i]];
    }
    return res;
}