@@ -3,7 +3,7 @@ import Base: cumsum, cumprod, cummin, cummax, chol, abs2
33
44export constant, get_last_error, err_to_string, sort_index, fir, iir
55export mean_weighted, var_weighted, set_array_indexer, set_seq_param_indexer
6- export afeval, iota
6+ export afeval, iota, sortbykey
77
88const af_threshold = Ref (4 * 1024 * 1024 * 1024 )
99const af_gc_count = Ref (0 )
@@ -479,3 +479,10 @@ function iota{T,N}(dims::NTuple{N,Int}, typ::Type{T} = Int32)
479479 out,UInt32 (N),[dims... ],UInt32 (1 ),[1 ],af_type (T)))
480480 AFArray {T,N} (out[])+ T (1 )
481481end
482+
483+ function sortbykey {T1,T2,N} (keys:: AFArray{T1,N} ,values:: AFArray{T2,N} ,dim:: Integer ,isAscending:: Bool = true )
484+ out_keys = RefValue {af_array} (0 )
485+ out_values = RefValue {af_array} (0 )
486+ _error (ccall ((:af_sort_by_key ,af_lib),af_err,(Ptr{af_array},Ptr{af_array},af_array,af_array,UInt32,Bool),out_keys,out_values,keys. arr,values. arr,UInt32 (dim - 1 ),isAscending))
487+ (AFArray {T1,N} (out_keys[]),AFArray {T2,N} (out_values[]))
488+ end
0 commit comments