olá, fiz este programa para criar um vetor de 5 elementos. Como faço para ordenar os elementos do vetor?
public static void main(String[] args) {
int [] alunos = new int[10];
int i=0;
System.out.println("Insira um valor: ");
alunos[i]=new Scanner(System.in).nextInt();
do {
i++;
System.out.println("Insira um valor: ");
alunos[i]=new Scanner(System.in).nextInt();
} while (i!=4);
}
public Ordenar() {
}
public void iniciar() {
int[] alunos = new int[10];
for (int i = 0; i < 10; i++) {
System.out.println("Insira um valor: ");
alunos[i] = new Scanner(System.in).nextInt();
}
ordenar(alunos);
System.out.println("\n---------Valores que você digitou---------\n");
for(int aluno : alunos){
System.out.println(aluno);
}
}
public void ordenar(int[] valores) {
int aux = 0;
for (int a = 0; a < valores.length; a++) {
for (int b = 0; b < valores.length; b++) {
if (valores[a] < valores[b]) {
aux = valores[a];
valores[a] = valores[b];
valores[b] = aux;
}
}
}
}