Implemented chat message sorting.