Sorting an array with TMath::Sort

Hi

I need to know how to sort an array with the inbuilt function Sort. I used the following code

void sorty()
{
double array_size=5;
const Double_t aray[5] = { 23, -1, 9999, 0, 4 };
const int index[5]={1,2,3,4,5};

  aray= TMath::Sort(5,aray,index,0);

    for(int i=0;i<5;i++){
            cout  << aray[i] << " ";
            }

}

I am getting the same array without being sorted as output.

Kindly help me in this.

Regards
Rajiv

Hi All,

I also require the index of the sorted array.

Rajiv

the index array is the output of TMath::Sort

Rene