mojo
mojo copied to clipboard
[Feature Request] [stdlib] Add `argsort` to the builtin `sort` module
Review Mojo's priorities
- [X] I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
Add argsort similar to numpy's
What is your motivation for this change?
sorting inplace is not an option if you need to sort multiple arrays keeping the same permutations
Any other details?
I don't know what would be needed in terms of Span
's capabilities. Because that permutation should be able to affect other items.
var my_list_distances = List[UInt64]()
var my_structures = List[MyStruct]()
...
var permutation = argsort(my_list_distances)
var ordered_structs = my_structures[permutation]
Or for now we can just return a list of indexes