I need to create a method that takes the highest value of an Array and passes it to the end of that Array so that the array is sorted without losing any value. I've tried it in many ways and still can not. Please correct my code.
My code:
public static void deslocaMaiorFinal(int[] Arranjo){
int maior = Arranjo[0];
int aux;
for(int c = 1; c < Arranjo.length; c++){
if(Arranjo[c] > maior) maior = Arranjo[c];
}//end for
for(int c = (Arranjo.length - 1); c >= 0; c--){
if(Arranjo[Arranjo.length-1] != maior){
aux = Arranjo[c];
Arranjo[c] = maior;
Arranjo[c-1] = aux;
}//end if
}//end for
return;
}//end method