Fixed sorting by date (issue #2947)