code: func (addr *ResourceAddress) Less(other *ResourceAddress) bool {
  
  	switch {
  
  	case len(addr.Path) != len(other.Path):
  		return len(addr.Path) < len(other.Path)
  
  	case !reflect.DeepEqual(addr.Path, other.Path):
  		// If the two paths are the same length but don't match, we'll just
  		// cheat and compare the string forms since it's easier than
  		// comparing all of the path segments in turn, and lexicographic
  		// comparison is correct for the module path portion.
  		addrStr := addr.String()
  		otherStr := other.String()
  		return addrStr < otherStr
  
  	case addr.Mode != other.Mode:
  		return addr.Mode == config.DataResourceMode
  
  	case addr.Type != other.Type:
  		return addr.Type < other.Type
  
  	case addr.Name != other.Name:
  		return addr.Name < other.Name
  
  	case addr.Index != other.Index:
  		// Since "Index" is -1 for an un-indexed address, this also conveniently
  		// sorts unindexed addresses before indexed ones, should they both
  		// appear for some reason.
  		return addr.Index < other.Index
  
  	case addr.InstanceTypeSet != other.InstanceTypeSet:
  		return !addr.InstanceTypeSet
  
  	case addr.InstanceType != other.InstanceType:
  		// InstanceType is actually an enum, so this is just an arbitrary
  		// sort based on the enum numeric values, and thus not particularly
  		// meaningful.
  		return addr.InstanceType < other.InstanceType
  
  	default:
  		return false
  
  	}
  }
docs: // Less returns true if and only if the receiver should be sorted before
  // the given address when presenting a list of resource addresses to
  // an end-user.
  //
  // This sort uses lexicographic sorting for most components, but uses
  // numeric sort for indices, thus causing index 10 to sort after
  // index 9, rather than after index 1.