aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-03-21 08:45:34 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-03-21 08:45:34 -0600
commit1c7b59a4c221bde00f84a1873fca7ad0a27b0131 (patch)
tree53a318271e854c56a97d9a8b18c39553802419f7
parentFix Bucket.ForEach() comment. (diff)
parentFix Tx.Buckets() sort order. (diff)
downloaddedo-1c7b59a4c221bde00f84a1873fca7ad0a27b0131.tar.gz
dedo-1c7b59a4c221bde00f84a1873fca7ad0a27b0131.tar.xz
Merge pull request #65 from benbjohnson/fix-tx-buckets-sort-order
Fix Tx.Buckets() sort order.
-rw-r--r--bucket.go6
-rw-r--r--tx.go1
2 files changed, 7 insertions, 0 deletions
diff --git a/bucket.go b/bucket.go
index 3e3392c..dbd06f1 100644
--- a/bucket.go
+++ b/bucket.go
@@ -155,3 +155,9 @@ type BucketStat struct {
KeyCount int
MaxDepth int
}
+
+type bucketsByName []*Bucket
+
+func (s bucketsByName) Len() int { return len(s) }
+func (s bucketsByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+func (s bucketsByName) Less(i, j int) bool { return s[i].name < s[j].name }
diff --git a/tx.go b/tx.go
index 53f0456..ae6d103 100644
--- a/tx.go
+++ b/tx.go
@@ -89,6 +89,7 @@ func (t *Tx) Buckets() []*Bucket {
}
buckets = append(buckets, bucket)
}
+ sort.Sort(bucketsByName(buckets))
return buckets
}