aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/nm/nm.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/nm/nm.go')
-rw-r--r--src/cmd/nm/nm.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go
index 462c4c510f..4384af8fae 100644
--- a/src/cmd/nm/nm.go
+++ b/src/cmd/nm/nm.go
@@ -103,11 +103,11 @@ func nm(file string) {
switch *sortOrder {
case "address":
- sort.Sort(byAddr(syms))
+ sort.Slice(syms, func(i, j int) bool { return syms[i].Addr < syms[j].Addr })
case "name":
- sort.Sort(byName(syms))
+ sort.Slice(syms, func(i, j int) bool { return syms[i].Name < syms[j].Name })
case "size":
- sort.Sort(bySize(syms))
+ sort.Slice(syms, func(i, j int) bool { return syms[i].Size > syms[j].Size })
}
w := bufio.NewWriter(os.Stdout)
@@ -131,21 +131,3 @@ func nm(file string) {
}
w.Flush()
}
-
-type byAddr []objfile.Sym
-
-func (x byAddr) Len() int { return len(x) }
-func (x byAddr) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-func (x byAddr) Less(i, j int) bool { return x[i].Addr < x[j].Addr }
-
-type byName []objfile.Sym
-
-func (x byName) Len() int { return len(x) }
-func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-func (x byName) Less(i, j int) bool { return x[i].Name < x[j].Name }
-
-type bySize []objfile.Sym
-
-func (x bySize) Len() int { return len(x) }
-func (x bySize) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
-func (x bySize) Less(i, j int) bool { return x[i].Size > x[j].Size }