do sort by quality more efficiently