code: func (s *Server) sortNodesByDistanceFrom(source structs.QuerySource, subj interface{}) error {
  	// We can't sort if there's no source node.
  	if source.Node == "" {
  		return nil
  	}
  
  	// We can't compare coordinates across DCs.
  	if source.Datacenter != s.config.Datacenter {
  		return nil
  	}
  
  	// There won't always be coordinates for the source node. If there are
  	// none then we can bail out because there's no meaning for the sort.
  	state := s.fsm.State()
  	_, cs, err := state.Coordinate(source.Node, nil)
  	if err != nil {
  		return err
  	}
  	if len(cs) == 0 {
  		return nil
  	}
  
  	// Do the sort!
  	sorter, err := s.newSorterByDistanceFrom(cs, subj)
  	if err != nil {
  		return err
  	}
  	sort.Stable(sorter)
  	return nil
  }
docs: // sortNodesByDistanceFrom is used to sort results from our service catalog based
  // on the round trip time from the given source node. Nodes with missing coordinates
  // will get stable sorted at the end of the list.
  //
  // If coordinates are disabled this will be a no-op.