# MATLAB: How to – “sort” using mexCallMATLAB

embedded matlabmex-functionmexcallmatlabsort

Dear all,
I am writing a mex-function and need to sort some data using the mexCallMATLAB API so that I get the data in the required form. i.e I need the data in descending order along with the index values.
In matlab – [y,i] = sort(x,1,'descend'); does the job for me. Can I simulate the same through the mexCallMATLAB API? If yes, how does it fit in the syntax for the API?
or
Should I write a C-code for the same?
mxArray *In[3];mxArray *Out[2];In[0] = <your data>;In[1] = mxCreateDoubleScalar(1.0);In[2] = mxCreateString("descend");  mexCallMATLAB(2, Out, 3, In, "sort");