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

sort: possibility for deduplication #12763

Closed
stemar94 opened this issue Sep 26, 2015 · 6 comments
Closed

sort: possibility for deduplication #12763

stemar94 opened this issue Sep 26, 2015 · 6 comments
Milestone

Comments

@stemar94
Copy link

@stemar94 stemar94 commented Sep 26, 2015

Hi I'm missing the possibility for sorting+dedup via std lib.
So I implemented a function DedupSorted(data Interface) (n int) for the sort package.
It rearranges different elements of data to the front of the Interface
preserving order and returns the number of different elements.

So for example if I want to sort+dedup a slice of strings:

strings :=[]string{"c", "a", "b", "a", "b"}
sort.Strings(strings)
n:=sort.DedupSorted(sort.StringSlice(strings))
strings=strings[:n]
fmt.Println(strings)

would give me

[a b c]

If there is already something like this I would be happy to know and I'm sorry for filing this issue.
Comments are welcome.

Marvin

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 26, 2015

CL https://golang.org/cl/15016 mentions this issue.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 26, 2015
@minux
Copy link
Member

@minux minux commented Sep 26, 2015

@cznic
Copy link
Contributor

@cznic cznic commented Sep 26, 2015

If we have a sortutil package, perhaps.

sortutil.Dedupe ;-)

@rakyll
Copy link
Contributor

@rakyll rakyll commented Sep 27, 2015

Generally, it is better to propose new APIs on golang-dev mailing list first where more contributors are actively watching each discussion. We need to discuss this function's value with other contributors to reason why it should or should not be merged into the standard library and where it would fit.

@adg
Copy link
Contributor

@adg adg commented Sep 28, 2015

Generally, it is better to propose new APIs on golang-dev mailing list first where more contributors are actively watching each discussion.

Actually the correct place to propose new API additions and other changes is through the issue tracker.

https://golang.org/s/proposal-process

@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 28, 2015

I don't think this needs to live in the standard library, here is an
example of the functionality you want

http://godoc.org/github.com/xtgo/set#Uniq

On Mon, Sep 28, 2015 at 12:44 PM, Andrew Gerrand notifications@github.com
wrote:

Generally, it is better to propose new APIs on golang-dev mailing list
first where more contributors are actively watching each discussion.

Actually the correct place to propose new API additions and other changes
is through the issue tracker.

https://golang.org/s/proposal-process


Reply to this email directly or view it on GitHub
#12763 (comment).

@stemar94 stemar94 closed this Mar 26, 2016
@golang golang locked and limited conversation to collaborators Mar 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.