Re-apply event sorting changes from #6012

#6012 
#6004