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

Comments

@stemar94
Copy link

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

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 commented Sep 26, 2015 via email

@cznic
Copy link
Contributor

cznic commented Sep 26, 2015

If we have a sortutil package, perhaps.

sortutil.Dedupe ;-)

@rakyll
Copy link
Contributor

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 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

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).

@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
Development

No branches or pull requests

8 participants