erotavlas
July 14th, 2013, 12:40 PM
Hi,
suppose I have three arrays a1, a2 and a3 of the same size in which the elements are linked. The link means that if an element in the first array a1 changes position then also the corresponding elements in the other arrays a2, a3 change position. If an element of the second array a2 changes position then only the corresponding element of the array a3 changes position.
For instance
a1 a2 a3
0 1 2
1 1 3
1 0 4
0 2 5
first step
a1 a2 a3
0 1 2
0 2 5
1 1 3
1 0 4
second step
a1 a2 a3
0 1 2
0 2 5
1 0 4
1 1 3
In fact I have to sort both the first two arrays in consecutive order. First, I sort the array a1 and then I reorder the elements of the second array a2 and third array a3. Then, I sort the array a2 and I reorder the elements of the third array.
If I use the standard quick sort function provided by the C library I lost the indexes reference before and after the sort. Is there a way to achieve this by using standard function or I have to write by hand the sorting algorithm?
Thank you
suppose I have three arrays a1, a2 and a3 of the same size in which the elements are linked. The link means that if an element in the first array a1 changes position then also the corresponding elements in the other arrays a2, a3 change position. If an element of the second array a2 changes position then only the corresponding element of the array a3 changes position.
For instance
a1 a2 a3
0 1 2
1 1 3
1 0 4
0 2 5
first step
a1 a2 a3
0 1 2
0 2 5
1 1 3
1 0 4
second step
a1 a2 a3
0 1 2
0 2 5
1 0 4
1 1 3
In fact I have to sort both the first two arrays in consecutive order. First, I sort the array a1 and then I reorder the elements of the second array a2 and third array a3. Then, I sort the array a2 and I reorder the elements of the third array.
If I use the standard quick sort function provided by the C library I lost the indexes reference before and after the sort. Is there a way to achieve this by using standard function or I have to write by hand the sorting algorithm?
Thank you