Add GALLERY_SORT_BY_DATE option (Issue #667)

This fixes #667 I would like to land it for 6.1