Fix date sorting on history page