Created
June 19, 2012 14:34
-
-
Save sanrodari/2954544 to your computer and use it in GitHub Desktop.
Ordenamiento con comparator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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