Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify documentation about sortedUniq #3310

Merged
merged 1 commit into from
Aug 9, 2017
Merged

Conversation

potmo
Copy link

@potmo potmo commented Aug 9, 2017

clarify that sortedUniq only works on sorted arrays

clarify that sortedUniq only works on sorted arrays
@jsf-clabot
Copy link

jsf-clabot commented Aug 9, 2017

CLA assistant check
All committers have signed the CLA.

@gnapse
Copy link

gnapse commented Jan 8, 2018

Just to be clear, technically sortedUniq work if the array is so that it guarantees that all items with the same value are consecutive, even if the array is not sorted. Is that correct?

In the case of sortedUniqBy, it works if the array is so that all items for which the iteratee function yields a certain value, appear consecutively in the array.

I don't mean to imply with this that the documentation should go to this level of details. It's just that I'm using sortedUniqBy in a situation where I've got an array of objects, all of which have name and id: I want to sort by name, and then remove duplicates by id.

// using the fp versions cause the argument order is preferable
sortedUniqBy('id', sortBy('name', array))

After the array is sorted by name, all items with the same id are guaranteed to appear consecutively, but not necessarily in order by id.

@lock
Copy link

lock bot commented Jan 8, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

4 participants