code: function localeSort(a1, a2) {
      if (a1 !== undefined && a1.localeCompare) {
          return a1.localeCompare(a2);
      }
      return a1 > a2 ? 1 : (a1 < a2 ? -1 : 0);
  }
docs: This comparator can be passed to the sort function on javascript arrays.