It is always nice to have one function that can sort arrays both in ascending and descending directions. Here is such a sorting method based on the bubble sorting algorithm. It takes exactly two parameters: an array and a comparison function.
You need to create an object that represents a comparison function and assign it to the comparator variable. The comparison function should take 2 parameters and return the minimum of them if the array should be sorted in ascending order, and the maximum of them if the array should be sorted in descending order.
Use isAscending variable to determine the sorting order. If the variable is true, then you need to sort the array in ascending order, otherwise, in descending order.
It is highly recommended to use method references to solve this task. There are several ways to do it, you can choose any of them. But if it is difficult for you, you can use lambda expressions as well.