je veux lister en utilisant deux arguments
la premiere liste selon les stars puis lister cette liste de star selon le nbre de votes :
j' ai utiliser Collections.sort:
AssertsStatics c'est une classe qui contient :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Collections.sort( list(), AssetStatistics.STARS_COMPARATOR ); Collections.sort( list(), AssetStatistics.VOTES_COMPARATOR );
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 static public final Comparator<AssetStatistics> VOTES_COMPARATOR = new Comparator<AssetStatistics>() { public int compare(AssetStatistics first, AssetStatistics second) { return (int) Math.signum( second.getVotesCount()- first.getVotesCount() ); } }; static public final Comparator<AssetStatistics> STARS_COMPARATOR = new Comparator<AssetStatistics>() { public int compare(AssetStatistics first, AssetStatistics second) { return (int) Math.signum( second.getStarsCount()- first.getStarsCount() ); } };
Partager