code: func EventScore(e models.Event) int {
  	lrp, crashed := getEventLRP(e)
  
  	// sort crashed events first to be backward compatible with the old
  	// event stream which emitted the crashed event before the
  	// remove/changed events.
  	if crashed {
  		return 2
  	}
  
  	// this is an event with a running instance, this should be emitted before
  	// any other event, such as removed ro changed event to non-running state.
  	if lrp != nil && lrp.State == models.ActualLRPStateRunning {
  		return 1
  	}
  
  	// The event is either a RemovedEvent or a ChangedEvent (to a non-RUNNING
  	// state).  These are prioritized last, because those events cause loss of
  	// routability.
  	return 0
  }
docs: // Determine the score of an event. An event with higher score should be
  // emitted before lower ones.  The score based ordering ensures continuous
  // routability, so events with running instances should be emitted first
  // followed by remove events.