I would like to know how to exlcude (not remove) particular object and then sort nest array object in javascript, Below function that sorts array object. i need to exclude the objects that is not having amount property and then sort the object having only amount in javascript and map the object(need to use exluded obj and sorted obj).
this.providerList = [{id:"transferwise", amount:"1000"}, {id:"wordlremit", amount:"4000", {id:"instarem", amount:"3000"}, {country: "Singapore", scn: "SG"}, {country: "India", scn: "IN"}];
sortAndFilterProviders() {
let myList = [];
myList = [...this.providerList];
myList.push.apply(myList, this.apiproviderdata.apiproviders);
// var mergeList = myList.concat(this.query);
// console.log(mergeList);
myList.sort(function (a, b) {
var a1 = a.amount, b1 = b.amount;
if (a1 == b1) return 0;
return a1 > b1 ? 1 : -1;
});
this.providerList = [...myList];
return this.providerList;
}
expected output
country: Singapore, India
Sorted Amount : Transferwise , Instarem, Worldremit