proper sorting of events