MultiColumnSorting documentation suggestion

Tags: #<Tag:0x00007f8b1de731c8>

I was pleased to see that the MultiColumnSorting add-in was included in 6.0, and happily removed my own implementation in favour of this one.

However, while I was trying to get a custom sort column working (I display areas in m² or hectares, but want it to sort correctly), I found that clicking on the column header once rendered the column in ascending order, and a second click also rendered the column in ascending order. My fault, I didn’t realise that I had to include the sortOrder parameter in the compareFunctionFactory, and use that from within my comparator.

It looks like this now:

multiColumnSorting: {
  compareFunctionFactory: function (sortOrder) {
    return function comparator (a, b) {
      const an = mvp3app.parseArea(a);
      const bn = mvp3app.parseArea(b);
      return sortOrder === 'desc' ? bn - an : an - bn;
    }
  }
}

It would be helpful to include this in the documentation, as I started out assuming that HOT would negate the comparison result if it was in descending order.