Fix problem with sorting date fields

Introduced a couple of commits ago when the localeCompare() stuff was
added.