added sorting tasks based on priority