In my VueJS project, I am working with data fetched from an API using axios. The data consists of projects with various properties such as year, location, and tags like house or park. I have implemented a filtering system to sort the projects based on a specific property:
sortby(data) {
// data = {prop: "year", tag: "house"}
//
if (data.prop === "year") {
this.projects.sort((a, b) => (a[data.prop] < b[data.prop] ? 1 : -1));
} else {
this.projects.sort((a, b) => (a[data.prop] < b[data.prop] ? -1 : 1));
}
},
However, after sorting the projects, I now want to display only those objects that have the tag equal to "house". Can anyone suggest how I can achieve this? Thank you!