0

I have an array "projectList" that i'm sorting with following function.

sort(key) {
  this.projectsList.sort((a, b) => (a[key] > b[key] ? 1 : -1))
}

When calling function, lets say sort('title'), it sorts the projects by title. All works fine.

Some of the keys that i need to sort by are deeper inside my array object. Normaly i'd access the value by this.projectsList.taxonomies.project-type.name

How do i pass the "project-type.name" value to sort function so i could sort the array by it?

0 Answers0