How to sort and filter tasks