def METHOD_NAME(self, sorted_array, unsorted_array, field_name, msg, check=True):
    if field_name == 'coord_id':
        if sorted_array.min() < 0:
            msg = '%s.min()=%s; did you allocate & build it?\n' % (
                field_name, sorted_array.min())
            raise RuntimeError(msg)
    else:
        if sorted_array.min() < 1:
            msg = '%s.min()=%s; did you allocate & build it?\n' % (
                field_name, sorted_array.min())
            raise RuntimeError(msg)
    if not array_equal(argsort(sorted_array), arange(len(sorted_array))):
        msg2 = '%s is not sorted\nsorted_array=%s' % (msg, sorted_array)
        raise RuntimeError(msg2)
    if not isinstance(self.n, (int64, int)):
        raise TypeError('field_name=%s n=%s type=%s' % (field_name, self.n, type(self.n)))
    if not isinstance(check, bool):
        raise TypeError('check should be a bool; check=%r' % check)
    if unsorted_array is None:
        i = slice(None)
        if self.n == 1:
            i = array([0], dtype='int32')
        return i
    else:
        i = searchsorted(sorted_array, unsorted_array)
        i.astype('int32')
        if check:
            try:
                sorted_array_i = sorted_array[i]
            except IndexError:
                #msg = 'sorted_array_i = sorted_array[i] - %s\n' % field_name
                msg = 'sorted_%s=%s\n' % (field_name, sorted_array)
                msg += 'i=%s' % (i)
                raise IndexError(msg)
            if not array_equal(sorted_array_i, unsorted_array):
                # undefined nodes/elements
                #print('unsorted %s' % unsorted_array)
                #print('sorted %s' % sorted_array)
                #pass
                msg2 = 'Undefined %s\n' % msg
                msg2 += 'diff=%s\n' % setdiff1d(unsorted_array, sorted_array)
                msg2 += 'sorted %s= %s; n=%s\n' % (field_name, str(sorted_array), len(sorted_array))
                msg2 += 'unsorted %s = %s\n' % (field_name, unsorted_array)
                msg2 += 'sorted %s[i]= %s\n' % (field_name, sorted_array[i])
                msg2 += 'i=%s\n' % i
                raise RuntimeError(msg2)
    if isinstance(i, (int64, integer_types)):
        i = array([i], dtype='int32')
    return i