Have you tried a counif to determine the frequeancy/quantity, and then base your sort on that?