Reputation: 11837
So, I would expect this to sort, but it isn't.
_.uniq(array, [isSorted], [iteratee], [thisArg])
so
_.uniq([10,3,13,1,0,2], true);
I run that, and it doesn't sort. I'd expect it to return: [0,1,2,3,10,13]
Upvotes: 0
Views: 260
Reputation: 10163
That's not what the isSorted
parameter does.
[isSorted] (boolean): Specify the array is sorted. - https://lodash.com/docs#uniq
does not mean it will also sort the array for you but that if you set it to true then it's expecting an already sorted array.
Providing true for isSorted performs a faster search algorithm for sorted arrays.
It's an optimization in that the algorithm for "Creates a duplicate-free version of an array" is a lot faster if the array is already sorted.
Upvotes: 2