It's better than what you had before but the whole thing could still be done with a single call to the sort method and a custom comparison function. Also you should avoid repeatedly calling Date.parse in the comparison function. On average the number of comparison is O(n log n) so your sortByDueDate function slows down the sorting algorithm tremendously by forcing it to do some date parsing every time it tries to compare two elements.
It's better than what you had before but the whole thing could still be done with a single call to the sort method and a custom comparison function. Also you should avoid repeatedly calling Date.parse in the comparison function. On average the number of comparison is O(n log n) so your sortByDueDate function slows down the sorting algorithm tremendously by forcing it to do some date parsing every time it tries to compare two elements.
Thank you for the feedback. If you have time to share and wouldn't mind, I would love to see your solution!