Active record help - sorting by number of paintings

An artist has many paintings.

I am having trouble doing this. How can I make Active Record retrieve
and sort all artists based on the number of paintings. The record
should also show the number of paintings of each artist.

By the way, I am using PgSql.