properly sort events