Permalink
Browse files

use sort.Reverse

  • Loading branch information...
1 parent 38d588f commit 95caa734b6431f207fb44f12ef7d37e7e55817ad @xiang90 xiang90 committed Sep 29, 2013
Showing with 2 additions and 2 deletions.
  1. +1 −1 server.go
  2. +1 −1 sort.go
View
@@ -849,7 +849,7 @@ func (s *Server) processAppendEntriesResponse(resp *AppendEntriesResponse) {
for _, peer := range s.peers {
indices = append(indices, peer.getPrevLogIndex())
}
- sort.Sort(uint64Slice(indices))
+ sort.Sort(sort.Reverse(uint64Slice(indices)))
// We can commit up to the index which the majority of the members have appended.
commitIndex := indices[s.QuorumSize()-1]
View
@@ -19,5 +19,5 @@ type uint64Slice []uint64
//--------------------------------------
func (p uint64Slice) Len() int { return len(p) }
-func (p uint64Slice) Less(i, j int) bool { return p[i] > p[j] } // descending order
+func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

0 comments on commit 95caa73

Please sign in to comment.