sort occurences by id