simplify thread ready sorting code