<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def commit_events(self):
 """Applies all outstanding `Event`s to the internal state """

        # Events are sorted such that, when applied in order, each event
        # represents a logical change in state. That is, an event never requires
        # future events' data in order to be parsed.
        # e.g. All ADDs must go before START READINGs
        #      All START READINGs before all READs
        for event in sorted(self._event_buf):
            self.store.record_event(event)
            self._snapshot.process_event(event)
        self._event_buf = []