github.com/jancarloviray/community@v0.41.1-0.20170124221257-33a66c87cf2f/core/section/github/sort.go (about) 1 // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. 2 // 3 // This software (Documize Community Edition) is licensed under 4 // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html 5 // 6 // You can operate outside the AGPL restrictions by purchasing 7 // Documize Enterprise Edition and obtaining a commercial license 8 // by contacting <sales@documize.com>. 9 // 10 // https://documize.com 11 12 package github 13 14 import "sort" 15 16 // sort owners in order that that should be presented. 17 type ownersToSort []githubOwner 18 19 func (s ownersToSort) Len() int { return len(s) } 20 func (s ownersToSort) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 21 func (s ownersToSort) Less(i, j int) bool { 22 return s[i].Name < s[j].Name 23 } 24 25 func sortOwners(in []githubOwner) []githubOwner { 26 sts := ownersToSort(in) 27 sort.Sort(sts) 28 return []githubOwner(sts) 29 } 30 31 // sort branches in order that that should be presented. 32 func sortBranches(in []githubBranch) []githubBranch { 33 sts := branchesToSort(in) 34 sort.Sort(sts) 35 return []githubBranch(sts) 36 }