Modify sorting codes to get list of tasks