compare array - arosh/arosh.github.com GitHub Wiki

https://github.com/golang/go/blob/b53f0f8c96a46b3cce0f1073787b74dd23f57a80/src/runtime/noasm.go#L38

func bytes_Compare(s1, s2 []byte) int {
	l := len(s1)
	if len(s2) < l {
		l = len(s2)
	}
	if l == 0 || &s1[0] == &s2[0] {
		goto samebytes
	}
	for i := 0; i < l; i++ {
		c1, c2 := s1[i], s2[i]
		if c1 < c2 {
			return -1
		}
		if c1 > c2 {
			return +1
		}
	}
samebytes:
	if len(s1) < len(s2) {
		return -1
	}
	if len(s1) > len(s2) {
		return +1
	}
	return 0
}

https://cpprefjp.github.io/reference/algorithm/lexicographical_compare.html

for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2) {
  if (*first1 < *first2) return true;
  if (*first2 < *first1) return false;
}
return first1 == last1 && first2 != last2;