sorting events properly