mardi 2 novembre 2021

Sorting numbers in multiple columns and moving empty or null to the bottom

I want to sort 2 columns and gettin the empty rows to the bottom, but i am a bit stuck on it. I've found multiple examples of both, and I can get them working separately from each other, but not simultaneous. Can somebody please provide me with an example?

    results.sort(   (a, b) => {
    var key = racetimefieldnames[setlastpartiallyfullcolumn];
    var keybefore = racetimefieldnames[setlastpartiallyfullcolumn-1];
    var aa = a[keybefore];
    var bb = b[keybefore];
    a = a[key];
    b = b[key];
    
    
    
    if(a === "" || a === null) return 1;
    if(b === "" || b === null) return -1;

    if (a > b) return 1;
    if (a < b) return -1;
    
    
    if (aa > bb) return 1;
    if (aa < bb) return -1;
    
    return 0;
    }); 

Aucun commentaire:

Enregistrer un commentaire