Allow to reverse taxonomy entries.
authorDavid Calavera <david.calavera@gmail.com>
Sat, 9 May 2015 22:21:30 +0000 (15:21 -0700)
committerbep <bjorn.erik.pedersen@gmail.com>
Tue, 12 May 2015 16:26:40 +0000 (18:26 +0200)
hugolib/taxonomy.go

index 0602e03b43f120d329d15ff0a05f495a71fdb615..1cab1a1ebeb7e265ec2ad972ab8e0499ca764687 100644 (file)
@@ -116,6 +116,14 @@ func (ie OrderedTaxonomyEntry) Term() string {
        return ie.Name
 }
 
+func (t OrderedTaxonomy) Reverse() OrderedTaxonomy {
+       for i, j := 0, len(t)-1; i < j; i, j = i+1, j-1 {
+               t[i], t[j] = t[j], t[i]
+       }
+
+       return t
+}
+
 /*
  * Implementation of a custom sorter for OrderedTaxonomies
  */