Hi,
it looks like the parameters for the function "sort_by_key" are in the wrong order in the ArrayFire-Python documentation.
The Python doc says values before keys:
http://arrayfire.org/arrayfire-python/arrayfire.algorithm.html#arrayfire.algorithm.sort_by_key
While the C/C++ doc states keys before values:
http://arrayfire.org/docs/group__sort__func__sort__keys.htm
After staring at the python doc and my results for a while the C/C++ doc confirmed my suspicion.