added sortByDate method so that it sorts when the task is added.