[Solved] Sort Array in Javascript [duplicate]


var goal = 4;
array.sort(function(a, b) {
    if (a.Seats == goal) {
        return -1;
    } else if (b.Seats == goal) {
        return 1;
    } else { // If neither matches the goal, order them by Seats
        return a.Seats - b.Seats;
    }
});

0

solved Sort Array in Javascript [duplicate]