aboutsummaryrefslogblamecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go
blob: a13c0ec419af372327b471683b057cd8f56df3e3 (plain) (tree)






















                                                       
package hclwrite

import (
	"github.com/hashicorp/hcl2/hcl/hclsyntax"
)

type nativeNodeSorter struct {
	Nodes []hclsyntax.Node
}

func (s nativeNodeSorter) Len() int {
	return len(s.Nodes)
}

func (s nativeNodeSorter) Less(i, j int) bool {
	rangeI := s.Nodes[i].Range()
	rangeJ := s.Nodes[j].Range()
	return rangeI.Start.Byte < rangeJ.Start.Byte
}

func (s nativeNodeSorter) Swap(i, j int) {
	s.Nodes[i], s.Nodes[j] = s.Nodes[j], s.Nodes[i]
}