I am trying to make a function, that allows you to sort
the dates in descending or ascending order. However, I'm not too sure how I should go about this. This is what I've worked out so far, but got completely stuck:
public void sortByYear() {
String askID = JOptionPane.showInputDialog(null, "Would you like to sort by ascending or descending?");
if(askID.equalsIgnoreCase("ascending")){
for(String datePersons : personList){
String[] splitPerson = datePersons.split("_");
String date = splitPerson[5];
}
} else if(askID.equalsIgnoreCase("descending")){
}
}
The format that my ArrayList
works with, is this: ID_NAME_MAIL_PHONE_CITY_DATETIME#
Which in the ArrayList
, with data in it, looks like this:
7_Geoffrey Wolf_fermentum.risus@malesuadaaugue.net_1-382-295-5799_Warwick_2010-03-27 09:47:41
If I got 99 different persons with different dates, how would I be able to sort them? I used this part to split and find the dates:
String[] splitPerson = datePersons.split("_");
String date = splitPerson[5];
Best Regards.