Example 1 — Official: Sort Nested Arrays
Call sort on every nested array.
_.invokeMap([[5, 1, 7], [3, 2, 1]], "sort");
// → [[1, 5, 7], [1, 2, 3]] How It Works
- Path.
"sort"resolves to each array’ssortmethod. - Call. Lodash runs
sortwith that array asthis. - Collect. Each sorted array is pushed into a new results list.
- Mutate. The nested arrays themselves are reordered in place.

