You can use Arrays.sort()
to sort your array before feeding it, each of the following describe how to achieve one thing you asked for – try to do each on the array (one at a time) before invoking sort(a)
To sort the array in ascending order:
Arrays.sort(a);
To sort the array in descending order:
Arrays.sort(a,Collections.reverseOrder());
To set constant value to each element in the array:
for (int i = 0; i < a.length; i++) a[i] = 0.25;
To partially sort a list (25% sorted):
Arrays.sort(a,0,a.length/4);
Bonus: to print the array (for debugging purposese usually):
System.out.println(Arrays.toString(a));
solved How to create various types of inputs in order to test my algorithm? [closed]