score:2

Accepted answer

Your best option, I think, is instead to filter the items in that array out of the dataset, then concatenate them to the front of it.

For example:

var removed = [];
climate = climate.filter(function(a) {
    if(dotscountries.indexOf(a.country) > -1) {
        removed.push(a);
        return false;
    }
    return true;
});
// if you actually want climate sorted, then sort it now
climate.sort(cmp); removed.sort(cmp);
climate = removed.concat(climate);

This will sort the two pieces independently, and put the elements in dotcountries at the front of the array.


Related Query