How to programmatically get the most selling products for a particular category?

A post was split to a new topic: How to programmatically get the most viewed products for a particular category?