Since I'm guessing you have 2 dynamic arrays that stores name and cost ArraySort() is out of the question since it won't match the other array.
You could either make your own sorting function using ArraySwap on both arrays to keep them synced.
Another option is to create a new array that works like a key to both arrays and sort that using 1DCustom.
I can't write it for you since the function you supplied is missing the name array...
EDIT:
Here's the basics of the first method:
Code:
new size = ArraySize(hArray);
for ( new i = 1 ; i < size ; i++ ) {
for ( new j = i ; j > 0 ; j-- ) {
if ( ArrayGetCell(hArray, j) < ArrayGetCell(hArray, j - 1) ) { // Use < for ascending and > for descending.
ArraySwap(hArray, j, j - 1);
ArraySwap(hStringArray, j, j - 1);
}
else
break;
}
}
__________________