Add event sorting functions.