def _newnames(datatype, order):
    """
    Given a datatype and an order object, return a new names tuple, with the
    order indicated
    """
    oldnames = datatype.names
    nameslist = list(oldnames)
    if isinstance(order, str):
        order = [order]
    seen = set()
    if isinstance(order, (list, tuple)):
        for name in order:
            try:
                nameslist.remove(name)
            except ValueError:
                if name in seen:
                    raise ValueError('duplicate field name: %s' % (name,))
                else:
                    raise ValueError('unknown field name: %s' % (name,))
            seen.add(name)
        return tuple(list(order) + nameslist)
    raise ValueError('unsupported order value: %s' % (order,))
