Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
use sort.Reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Sep 29, 2013
1 parent 38d588f commit 95caa73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.