Fix sorting by task & port to new api