Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. package main
  2.  
  3. import "sort"
  4.  
  5. // ByteSlice attaches the methods of sort.Interface to []byte, sorting in
  6. // increasing order.
  7. type ByteSlice []byte
  8.  
  9. func (s ByteSlice) Len() int { return len(s) }
  10. func (s ByteSlice) Less(i, j int) bool { return s[i] < s[j] }
  11. func (s ByteSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
  12.  
  13. // Sort is a convenience method.
  14. func (s ByteSlice) Sort() {
  15. sort.Sort(s)
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement