wcscmp method

int wcscmp(
  1. List<wchar_t> s1,
  2. List<wchar_t> s2
)

Compares the wide string s1 to the wide string s2. Returns 0 if they are equal, a negative value if s1 is less than s2, and a positive value if s1 is greater than s2.

Implementation

int wcscmp(List<wchar_t> s1, List<wchar_t> s2) {
  int len = min(s1.length, s2.length);
  for (int i = 0; i < len; i++) {
    if (s1[i] != s2[i]) {
      return s1[i] < s2[i] ? -1 : 1;
    }
  }
  if (s1.length < s2.length) return -1;
  if (s1.length > s2.length) return 1;
  return 0;
}