summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-08-27 18:23:45 -0700
committerRob Pike <r@golang.org>2009-08-27 18:23:45 -0700
commit3b32bf355aee497309c76f8a857b226aed14f75e (patch)
tree4c009db28e20bd8a785a475ce1ef6007429eaa2d /src
parentdc0bb7a287b7dc662071db7236f2f2f9f02b7614 (diff)
downloadgolang-3b32bf355aee497309c76f8a857b226aed14f75e.tar.gz
add Sort methods for convenience types
R=gri DELTA=9 (9 added, 0 deleted, 0 changed) OCL=34000 CL=34003
Diffstat (limited to 'src')
-rw-r--r--src/pkg/sort/sort.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pkg/sort/sort.go b/src/pkg/sort/sort.go
index 99ba0a0ef..70c746de6 100644
--- a/src/pkg/sort/sort.go
+++ b/src/pkg/sort/sort.go
@@ -152,6 +152,9 @@ func (p IntArray) Len() int { return len(p); }
func (p IntArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p IntArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
+// Sort is a convenience method.
+func (p IntArray) Sort() { Sort(p); }
+
// FloatArray attaches the methods of SortInterface to []float, sorting in increasing order.
type FloatArray []float
@@ -160,6 +163,9 @@ func (p FloatArray) Len() int { return len(p); }
func (p FloatArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p FloatArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
+// Sort is a convenience method.
+ffunc (p FloatArray) Sort() { Sort(p); }
+
// StringArray attaches the methods of SortInterface to []string, sorting in increasing order.
type StringArray []string
@@ -168,6 +174,9 @@ func (p StringArray) Len() int { return len(p); }
func (p StringArray) Less(i, j int) bool { return p[i] < p[j]; }
func (p StringArray) Swap(i, j int) { p[i], p[j] = p[j], p[i]; }
+// Sort is a convenience method.
+ffunc (p StringArray) Sort() { Sort(p); }
+
// Convenience wrappers for common cases