Creato da pastuweb.com
Share My Page
My Social Accounts
Account FaceBook Account LinkedIn Account Twitter Account Google Plus Account Git Hub

For instance, I want to order my list of measures by date descending:

Collections.sort(listaFinale, new Comparator<Misure>(){
         @Override
         public int compare(Misure o1, Misure o2) {
                  return o2.getD_misura().compareTo(o1.getD_misura());
         }
});

by date ascending:

Collections.sort(listaFinale, new Comparator<Misure>(){
         @Override
         public int compare(Misure o1, Misure o2) {
                  return o1.getD_misura().compareTo(o2.getD_misura());
         }
});

If I want to invert a List elements:
Collections.sort(listaFinale, Collections.reverseOrder());