code: func (is slotsByRunningState) Less(i, j int) bool {
  	iRunning := false
  	jRunning := false
  
  	for _, ii := range is[i] {
  		if ii.Status.State == api.TaskStateRunning {
  			iRunning = true
  			break
  		}
  	}
  	for _, ij := range is[j] {
  		if ij.Status.State == api.TaskStateRunning {
  			jRunning = true
  			break
  		}
  	}
  
  	if iRunning && !jRunning {
  		return true
  	}
  
  	if !iRunning && jRunning {
  		return false
  	}
  
  	// Use Slot number as a tie-breaker to prefer to remove tasks in reverse
  	// order of Slot number. This would help us avoid unnecessary master
  	// migration when scaling down a stateful service because the master
  	// task of a stateful service is usually in a low numbered Slot.
  	return is[i][0].Slot < is[j][0].Slot
  }
docs: // Less returns true if the first task should be preferred over the second task,
  // all other things being equal in terms of node balance.