int A = 300;
int B = 400;
int C = 1000;
int D = 500;
int []abcd = {A,B,C,D};
Arrays.sort(abcd); // the sequence of array elements will be {300, 400, 500,1000}
I wanted to change the value of the variables A,B,C,D according to their location in the array after sorting.
e.g variable A is located at index 0, so the value of A change to 1 instead of 300, variable B is located at index 1, so the value of B change to 2 instead of 400, variable D is located at index 2, so the value of D change to 3 instead of 500, variable C is located at index 3, so the value of C change to 4 instead of 1000,
The final value of the variable will be: A = 1; B = 2; C = 4; D = 3;