Answer:
Step-by-step explanation:
Some of the information provided in the question was very counterintuitive which made understanding what was actually required very difficult. Regardless here is the function requested, it takes an array which is currently a type float but can be changed to whatever you need (since the actual type was missing in the question) and the min_or_max argument which takes in either a 0 to sort in descending order or a 1 to sort in ascending order. Finally, it prints out the entire array.
public void minMaxFunc(float[] input, int min_or_max) {
if (min_or_max == 0) {
int last = input.length - 1;
int middle = input.length / 2;
for (int i = 0; i <= middle; i++) {
float temp = input[i];
input[i] = input[last - i];
input[last - i] = temp;
}
} else if (min_or_max == 1) {
float temp = 0;
for (int i = 0; i < input.length; i++) {
for (int j = i+1; j < input.length; j++) {
if(input[i] > input[j]) {
temp = input[i];
input[i] = input[j];
input[j] = temp;
}
}
}
} else {
System.out.println("Wrong min or max value, enter 1 for max or 0 for min");
}
for (int x = 0; x < input.length; x++) {
System.out.println(input[x]);
}
}