I was in Processing when I ran into this problem:
In Javascript there is a "sort()" function for arrays. Parameters can be specified to this function, being able to create for example:
array.sort((a, b) => b - a);
eitherarray.sort((a, b) => b - 2 * a);
I know that in Java there is a method to sort arrays, but you can't put the parameters that Javascript allows.
The solution to this problem is simple to solve, but more correct if somehow the function could be passed as a parameter.
The solution that I have done (in answers) has been an "order()" function with 3 or 4 parameters with very clear limitations (only 1 operation that passes through a character, it only works for an array of Int). Because of that, any answer that is valid and manages to fix my problems will be marked as valid.
I've tried creating that sort for java and although it only works for int[] arrays and only supports <+, -, *, /> operators, it allows the function to be done in reverse.
I started wondering if it could be done with some library, and with some java math (importing Math.signum(x) for operations) but I see that it has been much easier.
To use the function you just have to use sort(array_to_sort, operation between single quotes: ' ' , true if we want it to be sorted backwards ).
This is the code I have used: