code: func (s *Server) newSorterByDistanceFrom(cs lib.CoordinateSet, subj interface{}) (sort.Interface, error) {
  	switch v := subj.(type) {
  	case structs.Nodes:
  		return s.newNodeSorter(cs, v)
  	case structs.ServiceNodes:
  		return s.newServiceNodeSorter(cs, v)
  	case structs.HealthChecks:
  		return s.newHealthCheckSorter(cs, v)
  	case structs.CheckServiceNodes:
  		return s.newCheckServiceNodeSorter(cs, v)
  	default:
  		panic(fmt.Errorf("Unhandled type passed to newSorterByDistanceFrom: %#v", subj))
  	}
  }
docs: // newSorterByDistanceFrom returns a sorter for the given type.