Sort containers by message date and id

Inspired by the `sort_key` already there for Thread class.

Fixes #179.