ordering messages based on date