Skip to content

Instantly share code, notes, and snippets.

@sanrodari
Created June 19, 2012 14:34
Show Gist options
  • Select an option

  • Save sanrodari/2954544 to your computer and use it in GitHub Desktop.

Select an option

Save sanrodari/2954544 to your computer and use it in GitHub Desktop.
Ordenamiento con comparator
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package standaloneexamples;
import java.util.*;
/**
*
* @author USUARIO WINDOWS
*/
public class StandaloneExamples {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
List<DatoConCalendar> datos = new ArrayList<DatoConCalendar>();
Collections.sort(datos, new Comparator<DatoConCalendar>(){
@Override
public int compare(DatoConCalendar o1, DatoConCalendar o2) {
return o2.getCalendar().compareTo(o1.getCalendar());
}
});
}
}
class DatoConCalendar {
private Calendar calendar;
public Calendar getCalendar() {
return calendar;
}
public void setCalendar(Calendar calendar) {
this.calendar = calendar;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment