I am taking a CSV file of delivery times (unordered) and I need to sort them by time to use the data.
I am storing the necessary info in a LinkedList in my roadDataToBeSorted data structure which consists of 3 strings: rdName, rdZipCode, and rdDeliveryTime. My research so far says to use the LocalTime class since my time format in rdDeliveryTime is HH:MM:SS.
I'm not sure how I can turn my string into a LocalTime object I can then use the .isBefore() function to order my data.
for (int i = 0; i < stopOrderByDeliveryTime.size() - 1; i++) {
if (LocalTime(stopOrderByDeliveryTime.get(i).rdDeliveryTime).isBefore(LocalTime(stopOrderByDeliveryTime.get(i+1).rdDeliveryTime))) {
// add element at index (it is earlier than later elements)
} else {
// add element to end since it is later than all prior elements
}
}