Skip to content

Fixing bug in sort_by_key parameters #144

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

Merged
merged 1 commit into from
May 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions arrayfire/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,35 +473,35 @@ def sort_index(a, dim=0, is_ascending=True):
c_uint_t(dim), c_bool_t(is_ascending)))
return out,idx

def sort_by_key(iv, ik, dim=0, is_ascending=True):
def sort_by_key(ik, iv, dim=0, is_ascending=True):
"""
Sort an array based on specified keys

Parameters
----------
iv : af.Array
An Array containing the values
ik : af.Array
An Array containing the keys
iv : af.Array
An Array containing the values
dim: optional: int. default: 0
Dimension along which sort is to be performed.
is_ascending: optional: bool. default: True
Specifies the direction of the sort

Returns
-------
(ov, ok): tuple of af.Array
`ov` contains the values from `iv` after sorting them based on `ik`
(ok, ov): tuple of af.Array
`ok` contains the values from `ik` in sorted order
`ov` contains the values from `iv` after sorting them based on `ik`

Note
-------
Currently `dim` is only supported for 0.
"""
ov = Array()
ok = Array()
safe_call(backend.get().af_sort_by_key(c_pointer(ov.arr), c_pointer(ok.arr),
iv.arr, ik.arr, c_uint_t(dim), c_bool_t(is_ascending)))
safe_call(backend.get().af_sort_by_key(c_pointer(ok.arr), c_pointer(ov.arr),
ik.arr, iv.arr, c_uint_t(dim), c_bool_t(is_ascending)))
return ov,ok

def set_unique(a, is_sorted=False):
Expand Down