sort the returned tasks