I have an array of objects like this
[{ ‘a’: { id: 4 }}, { ‘b’: { id: 3 }}, { ‘c’: { id: 2 }}, { ‘d’: { id: 5 }}]
I want to know with lodash the sorting of the objects according to the id. I would expect to receive something like [‘d’, ‘a’, ‘b’, ‘c’].
I tried to search this but I didn’t find an answer which works with different keys in each object. I tried to do this with lodash’ different functions (many). So I thought there may be a good and maybe short way to solve this.
[{key: 'a', id: 4}, {key: 'b', id: 3}, …].