sorting results using itertools