Implements sorting by date