Salut a tous,
Je recherche un moyen pour trier une arraylist<string>
Dans la faq il est indiqué que l'on peut utiliser java.util.Collections.sort(ma_liste);
Mais ceci ne marche pas chez moi...
regardez plutot voici la liste que me ressort le "triage" :
Belle liste hein !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 2paleplan©©©©©©©zaza©E:/Docs/pazaz/pazaz sup/zeae/©©©©0©©© 3pale plan©©©©©©©zaza©E:/Docs/pazaz/pazaz sup/zeae/©©©©0©©© 3pale©©©©©©©zaza©E:/Docs/pazaz/pazaz sup/zeae/©©©©0©©© Intxxccv 110 061©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©0©©© Intxxccv 110 062©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©0©©© Intxxccv 110 063©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©29©©© Intxxccv 110 064©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©0©©© Intxxccv 110 065©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©15©©© Intxxccv 110 066©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©14©©© Intxxccv 110 067©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©0©©© Intxxccv 110 068©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©17©©© Intxxccv 110 069©©©©©©©zaza©E:/coolpintxxccv/Biume/©©©©25©©© JavaDay3-3©©©©©©©zaza©E:/Programmation/java/©©©©47©©© JavaDay5-3©©©©©©©zaza©E:/Programmation/java/©©©©114©©© Les Inconnus - Biouman (générique)©©©©©©©mpg©E:/Ma musique/chansons humouristiques/Parodies/©©©©0©©© aligngrid©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©© asmrebuild©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©© bidule©©©©©©©zaza©E:/Docs/pazaz/pazaz spe - Crash test/©©©©13©©© filecopy©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©© interpolationOpaciteGraph©©©©©©©zaza©E:/Programmation/flash/©©©©12©©© interpolationOpacite©©©©©©©zaza©E:/Programmation/flash/©©©©13©©© meshprogress©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccCOSMOSXpress/©©©©0©©© mov00228©©©©©©©mpg©E:/coolpirlande/Ring of Kerry-Alexis_27 10 06/©©©©0©©© projetsi©©©©©©©zaza©E:/Docs/Projet SI/ancien/©©©©0©©© rebuild©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©© seledgeandend©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©© session3_3©©©©©©©zaza©E:/Programmation/java/©©©©213©©© solverprogress©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccCOSMOSXpress/©©©©0©©© swfileopen©©©©©©©zaza©E:/Programmes/soyzerrtt03/program files/SolidWsdccdata/©©©©0©©©![]()
Mais comme vous pouvez le voir elle n'est pas triée...
Pourquoi ? Et comment faire pour trier une telle liste ?
PS : voici mon code :
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 BufferedWriter out = new BufferedWriter(new FileWriter(System.getProperty("user.dir")+ File.separator + "myfile.txt")); int i=0; int fin=db.size(); java.util.Collections.sort(db); while(i<fin) { out.write(db.get(i)); out.newLine(); i++; } out.close();
Partager