¿Hay alguna función que pueda ordenar los valores de mi matriz entera de menor a mayor? [cerrado]
Frecuentes
Visto 154 veces
2 Respuestas
5
Muy fácil:
int[] intarray;
// ...
Arrays.sort(intarray);
If you have a List instead:
List<Integer> numbers;
// ...
Collections.sort(numbers);
Respondido el 10 de Septiembre de 13 a las 00:09
3
int[] x= new int[] {1,2,3,4,0,-3};
Arrays.sort(x);
for(int temp: x) {
System.out.println( temp);
}
Respondido el 10 de Septiembre de 13 a las 00:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas java arrays sorting or haz tu propia pregunta.
¿Por qué no solo
System.out.println(Arrays.toString(temp));
? - bohemioI am just showing how this stud can do print - dan hunex
And I just showed you how to do it properly. And what's
i
declared for? - bohemioFrankly , even this student is not supposed to use Arrays.sort ,he has to learn how to implement sorting by himself and displaying things until he become expert. Anyway, thank you for your marvelous lecture - dan hunex
@DanHunex - Stud? Really? Where's the evidence? :-) - Stephen C