Sorting by absolute value in AG Dash Grid

I figured this out. In case it is helpful to someone else

var dagfuncs = window.dashAgGridFunctions = window.dashAgGridFunctions || {};

dagfuncs.absoluteComparator = function (num1, num2) {
    if (num1 === null && num2 === null) {
        return 0;
    }
    if (num1 === null) {
        return -1;
    }
    if (num2 === null) {
        return 1;
    }
    return Math.abs(num1) - Math.abs(num2);
}
4 Likes