func (s BySuffix) Less(i, j int) bool {
	if s[i].nr[0] == s[j].nr[0] {
		return s[i].nr[1] < s[j].nr[1]
	}
	return s[i].nr[0] < s[j].nr[0]
}
Less satisfies the sort interface. In this case, we check to see if the two
sort indices are equal. If they are then we check which of the second
indices is greater. If they aren't equal then we find out which of the
first indices is greater.
package suffix_array
import "sort"
type Suffix struct {
	nr  []int
	idx int
}
type SuffixResult []*Suffix
func (s SuffixResult) ToSuffixArray() []int {
	var suffixArray []int
	for _, e := range s {
		suffixArray = append(suffixArray, e.idx)
	}
	return suffixArray
}
func (s SuffixResult) Search(str, pat string) (int, int) {
	suffixArray := s.ToSuffixArray()
	n := len(suffixArray)
	start := 0
	end := n
	for start < end {
		mid := (start + end) / 2
		if pat > str[suffixArray[mid]:n] {
			start = mid + 1
		} else {
			end = mid
		}
	}
	suffixStart := start
	end = n
	for start < end {
		mid := (start + end) / 2
		if pat < str[suffixArray[mid]:n] {
			end = mid
		} else {
			start = mid + 1
		}
	}
	return suffixStart, end
}
type BySuffix []*Suffix
func (s BySuffix) Len() int {
	return len(s)
}
func (s BySuffix) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}