Sorting Arrays Of Objects With Lodash
Last updated
Was this helpful?
Last updated
Was this helpful?
The library comes with a couple functions for sorting collections of objects -- and .
Consider the following collection of pokemon:
This collection can be sorted in ascending order by the value of a key in the object using sortBy
.
If you want to control whether the sorting is in ascending or descending order, use orderBy
.
You can also do sorting with primary and secondary keys by including two values in the key sort array.
And if you want to indpendently control ascending/descending for these as well, you can.
Check out the to see it in action.