Skip to content

Add dims support to sort, sort!, sortperm and sortperm! - #117

Draft
shreyas-omkar wants to merge 1 commit into
JuliaGPU:mainfrom
shreyas-omkar:sh/sort-dims
Draft

Add dims support to sort, sort!, sortperm and sortperm!#117
shreyas-omkar wants to merge 1 commit into
JuliaGPU:mainfrom
shreyas-omkar:sh/sort-dims

Conversation

@shreyas-omkar

@shreyas-omkar shreyas-omkar commented Aug 24, 2026

Copy link
Copy Markdown
Member

Adds a dims keyword to sort/sort!/sortperm/sortperm! for portable per-slice N-D sorting across CPU and every GPU backend, using the same tag-and-lexicographic-sort strategy as AMDGPU.jl #1033

Sort or permute each 1D slice along an integer `dims` independently,
matching Base. The default `dims=:` keeps the existing flat behaviour.

There is no batched sort kernel, so each element is tagged with its slice
and the whole array is sorted once by (slice, value), then scattered back
into place. sortperm carries the original index as the payload and uses it
to break ties, keeping the permutation stable. This reuses the backend's
tuned sort and runs unchanged on CPU and every GPU backend.
@shreyas-omkar shreyas-omkar changed the title Add dims support to sort and sort! Add dims support to sort, sort!, sortperm and sortperm! Aug 24, 2026
@shreyas-omkar
shreyas-omkar marked this pull request as draft August 24, 2026 09:49
@shreyas-omkar

Copy link
Copy Markdown
Member Author

@christiangnrd Please take a look. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant