Thanks Bob, I really appreciate your help.
I tried it out right away and it looks like it's working, last steps to get the right data on the right place will definitely work out.
Here's the code I have now and the output.
I'll go work on getting the arrays in my class, to prevent all the memory allocation for each rendered frame.
Thanks again.
int *order = new int[mNrD3dMeshesBlended];
for(oc=0;oc<mNrD3dMeshesBlended;++oc) order[oc] = oc;
int *indices = new int[mNrD3dMeshesBlended];
for(oc=0;oc<mNrD3dMeshesBlended;++oc) indices[oc] = mMeshIndexBlended[oc];
int *dists = new int[mNrD3dMeshesBlended];
for(oc=0;oc<mNrD3dMeshesBlended;++oc) dists[oc] = mD3dMeshes[mMeshIndexBlended[oc]].mDistToCam;
std::sort(order, order+mNrD3dMeshesBlended, [&](int a, int b) { return dists[a]<dists[b]; });
Unsorted output:
0 Unsorted: 1 ,dist to cam: 95.6556
1 Unsorted: 3 ,dist to cam: 105.594
2 Unsorted: 5 ,dist to cam: 152.151
3 Unsorted: 7 ,dist to cam: 46.3681
4 Unsorted: 9 ,dist to cam: 39.37
Sorted:
Sorted: 4 39
Sorted: 3 46
Sorted: 0 95
Sorted: 1 105
Sorted: 2 152