This is the recommended way of using orderBy from lodash
const data = _.orderBy(array_of_objects, ['type','name'], ['asc', 'desc']); - instead of keys
is there a way to do something like this?
instead of object keys ['type','name'] can I pass key paths as string array like this ['type.id','name.entry']?
So that the expected result would be a sorted array based on deep values.
const data = _.orderBy(array_of_objects, ['type.id','name.entry'], ['asc', 'desc']); - instead of keys
I am asking this because we can access an objects deep properties using lodash _.get() like this.
_.get(object, 'a[0].b.c');
// => 3
So there must be a way of doing this with _.orderBy()
NB If there is a way of doing this in vanilla js, please suggest that also.
Currently in my case this is not getting sorted for every keys I pass ['type.id','name.entry'] only either of one is working.
If this is not possible please suggest how can I sort an array objects with deeply nested props based on multiple deeply nested props(passed as string paths)