Add custom key sorting function for times. #1052