QUOTE(ecresna @ 4 Aug, 2008 - 11:02 AM)

Hi all.
I'm trying to sort a 2D array by using qsort ANSI C, but is doesn't work .
I have a 4096x4 numbers array (double type) and I want to sort it by columns (sorting each column). At the moment I have this:
///I "copy" first column of 4096x4 array in other double pointer called column that is an array of pointers (a pointer for column)
for (k=0;k<col;k++)
{
for (m = 0; m < fil; m++) // fil=4096 col=4
{
*(column[k]+m) = big_array[m+k*fil];
}
}
// later I use this column pointer into qsort:
qsort (column[0], 10, sizeof(double), compare);
when I check column[0] is disordered.
What is wrong????
Thanks
This is how I would do it in vb.net translating to C should be to hard.
vb
Dim Tmp(4096) as Double
For col=0 to 3
For q=0 to 4095
Tm( q)=BigArray(col,q)
Next q
QuickSort(Tmp)' I don't know syntax for Quicksort
For q=0 to 4095
BigArray(col,q)=Tmp(q)
next q
Next col
This post has been edited by AdamSpeight2008: 4 Aug, 2008 - 04:37 AM