static int nanAwareCompare(double a, double b) {
        if (Double.isNaN(a)) return Double.isNaN(b) ? 0 : 1;
        if (Double.isNaN(b)) return -1;
        return Double.compare(a, b);
    }
The <i>cell_order</i> tensor function produces a tensor with the rank of each
value in the original tensor according to the given ordering

@author arnej
vespajlib/src/main/java/com/yahoo/tensor/functions/CellOrder.java