hcl/hclwrite/native_node_sorter.go
Martin Atkins 708abb8c97 Move the zcl package and its two parsing subpackages to "hcl" names
This is a super-invasive update since the "zcl" package in particular
is referenced all over.

There are probably still a few zcl references hanging around in comments,
etc but this takes care of most of it.
2017-09-11 16:40:37 -07:00

24 lines
444 B
Go

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]
}