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

array sorting by dimension #2484

Closed
ViralBShah opened this issue Mar 6, 2013 · 5 comments
Closed

array sorting by dimension #2484

ViralBShah opened this issue Mar 6, 2013 · 5 comments
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@ViralBShah
Copy link
Member

Matlab provides:

sort(A, [dim]) # A is nd
sortrows(A, [order]) # A is 2d

I believe we used to have these at some point. It would be nice to have sorting work on arrays. The API issue about operating on dimensions is already being discussed in #2265, and sort should also used whatever is concluded there.

JeffBezanson added a commit that referenced this issue Mar 24, 2013
this is a beautifully general function. we can use it for #2484
and similar missing functions.
it is also a really good function to focus on optimizing, and for honing
things like indexing behavior.
@ViralBShah
Copy link
Member Author

Should we implement this with the API described above, now that we have mapslices?

@mschauer
Copy link
Contributor

mapslices(sort, A, 1) would sort each column of A, not the columns (in lexicographic order). Am I missing something?

@JeffBezanson
Copy link
Member

Both of those functions are useful; here we just wanted the equivalent of matlab's sort(A,dim) which sorts each row or column.

@JeffBezanson
Copy link
Member

The sorting API provides a way to get the desired permutation of the rows/columns, by specifying a comparison function.

@damiendr
Copy link
Contributor

damiendr commented Dec 14, 2016

I'm looking for a way to sort columns in-place, but there doesn't seem to be a sortcols! nor a mapslices!, and sort! does not accept a SubArray either. Should I open a new issue? EDIT: nevermind, I see that just changed in 0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

4 participants