I have 3 arrays
a[n] , b[n] ,c[n]
a and b arrays are entered by the user and c is calculated as
c[i] = b[i] - a[i] + 1
Sorting the c array is easy. I sorted it by
Arrays.sort(c) method
Now I have to sort arrays a & b according to c as follows
For Example -
a[5] ={1 , 3 , 5 , 7 , 9 }
b[5] ={5 , 4 , 7 , 8 , 10 }
Then c[] will be calculated as
c[i] = b[i] - a[i] +1.
c[5] ={5 , 2 , 3 , 2 , 2}
Now sorting the c array results in
c[5] = { 2 , 2 , 2 , 3 , 5 }
Now I also want a[i] and b[i] as
a[5]={ 3 , 7 , 9 , 5 , 1 }
b[5]={ 4 , 8 , 10 , 7 , 5 }
such that the now the relationship between arrays will be maintained for each element 'i'
c[i] = b[i] - a[i] + 1