Skip to content

Commit

Permalink
wit: sort Packages in a Resolve when serializing to WIT
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Jun 9, 2024
1 parent 8626c96 commit 11cac3c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wit/wit.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ func (*Resolve) WITKind() string { return "resolve" }
//
// [WIT]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
func (r *Resolve) WIT(_ Node, _ string) string {
packages := slices.Clone(r.Packages)
slices.SortFunc(packages, func(a, b *Package) int {
return strings.Compare(a.Name.String(), b.Name.String())
})
var b strings.Builder
for i, p := range r.Packages {
for i, p := range packages {
if i > 0 {
b.WriteRune('\n')
b.WriteRune('\n')
Expand Down

0 comments on commit 11cac3c

Please sign in to comment.