Jeff,
Isn't that what FREQUENCY is designed for? I mean,
=SUM(FREQUENCY({1,2,3,4,5,6,7,8,9},{3,6,9}))
=SUM(FREQUENCY({1,2,3,4,5,6,7,8,9},{6,9}))
=SUM(FREQUENCY({1,2,3,4,5,6,7,8,9},{9}))
=SUM(FREQUENCY({1,2,3,4,5,6,7,8,9},{6,9,3}))
return the same result. Excel places them in "bins" per element size in data irrespective of the sort order.
Edit: In fact, I sometimes suspect that the extra element that FREQUENCY has [bins_array_size + 1], comes from some kind of comparison algorithm in the background for size sort.