Source file src/cmd/compile/internal/types/sort.go

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types
     6  
     7  // MethodsByName sorts methods by name.
     8  type MethodsByName []*Field
     9  
    10  func (x MethodsByName) Len() int           { return len(x) }
    11  func (x MethodsByName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
    12  func (x MethodsByName) Less(i, j int) bool { return x[i].Sym.Less(x[j].Sym) }
    13  
    14  // EmbeddedsByName sorts embedded types by name.
    15  type EmbeddedsByName []*Field
    16  
    17  func (x EmbeddedsByName) Len() int           { return len(x) }
    18  func (x EmbeddedsByName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
    19  func (x EmbeddedsByName) Less(i, j int) bool { return x[i].Type.Sym().Less(x[j].Type.Sym()) }
    20  

View as plain text