Hi,
I'm struggling with something which sounds fairly simple... although..
- I have a int array containing incices of meshes, say Meshes[5] = { 3, 1, 4, 9, 2};
- these indices point to objects (meshes) with a member 'distance' (float)
- say the meshes with indices above have: 10, 30, 40, 50, 15 as distance
What I want to achieve is the new index (int array) sorted on the descending order of the member floats..
I got so far to be able to sort the int array without the floats, and I got that far to sort the floats as an array (distances).
Simply don't know how to complete this goal...
Here's the code that partially does this.
Can someone help me out?
float *dists = new float[mNrD3dMeshesBlended];
for(oc=0;oc<mNrD3dMeshesBlended;++oc) dists[oc] = mD3dMeshes[mMeshIndexBlended[oc]].mDistToCam;
float elements = sizeof(dists) / sizeof(dists[0]);
std::sort(dists, dists+mNrD3dMeshesBlended, std::greater<float>());
// int elements = sizeof(mMeshIndexBlended) / sizeof(mMeshIndexBlended[0]);
// std::sort(mMeshIndexBlended, mMeshIndexBlended+mNrD3dMeshesBlended, std::greater<int>());