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}
Don't sort them. Put them in one array, have a second array initialized to all zeros, and count how many items are greater than or equal to each element. Then just transfer these counts back to the variables.