Coappearances: sort character list sidebar by number of links.

- Factor sorting code out into a function.