Fix task sorting