I am populating an ArrayList with 2 items from a sql database: An ID and a Date (stored as a string). I want to sort the ArrayList by the Date, and then loop over the sorted array to get back from the database the rest of the information.
Can I achieve this using ArrayList, and if so, HOW? OR
I need to create and populate a different type of Array, if so, what and how to sort it?
I will need to loop over the sorted array to get the rest of the information per record from the database.
I have the following code:
final ArrayList<String> firstList = new ArrayList<String>();
while (i<=numRows){
artID = helper.getTextFromTable(ArticlesTable, i, "achievementID");
Date = helper.getTextFromTable(ArticlesTable, i, "date");
firstList.add(artID);
firstList.add(Date);
i= i+1;
}
I have searched but have not found the answer. Thanks very much.