Sorting on facet results?

Hi,

Is there any combination of queries I can use to sort the results based on
facet results?

For example, I have three fields, "Date", "Hits" and "Logins" in a doc. Now,
given a date range, I need to get all the documents, such that the total of
"Hits" in the given date range is greater than 1000 and I need to sort the
result based on "Logins". Is this possible in es?

I get a feeling this can be done using terms_stats facet but I am not able
to figure out how.

Thanks for your time,
Hari