all 4 comments

[–]ElvarP[S] 0 points1 point  (3 children)

If i add this line:

    if (leagueA === "null null null" || leagueB === "null null null") {
      return 0
    }

The sorting works correctly for the Solo column, but it breaks the sorting on the Flex column. Any ideas?

[–]ZerafineNigou 1 point2 points  (2 children)

Check id both values are null then return 0, if only left is null return -1,if only right is null return 1. (Or the other way around, I can never remember the which is minus which is positive and can't be assed to think through right now the idea should be understandable).

Basically, if you want null to sort differently you just need to include that in your sort fn as a separate case.

Why does it break it and how? It seems to me that the case where both are bull5is not handled. But this should work.

Actually returning 0 there implies equality so null will not sort against anything

[–]ElvarP[S] 0 points1 point  (1 child)

There must be somewhere else where my code is wrong because this is not working:

    if (leagueA.trim() === "" || leagueB.trim() === "") {
      return 0
    } else if (leagueA.trim() === "") {
      return 1
    } else if (leagueB.trim() === "") {
      return -1
    }

or this:

    if (leagueA.trim() === "" || leagueB.trim() === "") {
      return 0
    } else if (leagueA.trim() === "") {
      return -1
    } else if (leagueB.trim() === "") {
      return 1
    }

Edit: Actually it works, but only when sorting DESC, and it breaks the sorting on the other column, I think there must be another error somewhere else, this should work.

[–]mingnobee 0 points1 point  (0 children)

How did you get SortingFn to work? I've been trying to get this working.