<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def user_agents(self):
 """ Retrieve user-agents, sorted by most common to least common. """

        return (self.get_query()
                .select(
                    PageView.headers['User-Agent'],
                    fn.Count(PageView.id))
                .group_by(PageView.headers['User-Agent'])
                .order_by(fn.Count(PageView.id).desc())
                .tuples())