hi all. I need to be able to sort a java array by ascending or preferably descending order. Once I have done this I need to be able to use the largest and smallest numbers (for example subtract the smallest number from the largest number in the array).
Please use the following array as an example in your responses. Obviously with the code now it will sort it in ascending order, but I do not know how to write code to do the sum 4 - -23.
int[] intArray = new int[] {4, 1, 3, -23};
Arrays.sort(intArray);
// [-23, 1, 3, 4]
P.S. how do I make the array descending as well?
thanks,
Jon