here is my case I am trying to sort an array with two name and crop equal true I am using lodash sortBy method
https://lodash.com/docs/4.17.11#sortBy
it working just fine with sorting string but not working with boolean filed
here is my code
const unsortedArray = [
{ name: "mina", lastName: "a", crop: false },
{ name: "aaa", lastName: "fa", crop: true },
{ name: "mina", lastName: "a", crop: true }
];
console.log("un sorted array ", unsortedArray);
console.log(
" sorted array ",
_.sortBy(unsortedArray , ["name" ,"crop"])
);
Use
_.orderBy(unsortedArray , ["name" ,"crop"], ["asc", "desc"]);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments