def _union_indexes(indexes, sort=True):
if len(indexes) == <NUM_LIT:0>:<EOL><INDENT>raise AssertionError('<STR_LIT>')<EOL><DEDENT>if len(indexes) == <NUM_LIT:1>:<EOL><INDENT>result = indexes[<NUM_LIT:0>]<EOL>if isinstance(result, list):<EOL><INDENT>result = Index(sorted(result))<EOL><DEDENT>return result<EOL><DEDENT>indexes, kind = _sanitize_and_check(indexes)<EOL>def _unique_indices(inds):<EOL><INDENT>"""<STR_LIT>"""<EOL>def conv(i):<EOL><INDENT>if isinstance(i, Index):<EOL><INDENT>i = i.tolist()<EOL><DEDENT>return i<EOL><DEDENT>return Index(<EOL>lib.fast_unique_multiple_list([conv(i) for i in inds], sort=sort))<EOL><DEDENT>if kind == '<STR_LIT>':<EOL><INDENT>result = indexes[<NUM_LIT:0>]<EOL>if hasattr(result, '<STR_LIT>'):<EOL><INDENT>return result.union_many(indexes[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>for other in indexes[<NUM_LIT:1>:]:<EOL><INDENT>result = result.union(other)<EOL><DEDENT>return result<EOL><DEDENT><DEDENT>elif kind == '<STR_LIT>':<EOL><INDENT>index = indexes[<NUM_LIT:0>]<EOL>for other in indexes[<NUM_LIT:1>:]:<EOL><INDENT>if not index.equals(other):<EOL><INDENT>if sort is None:<EOL><INDENT>warnings.warn(_sort_msg, FutureWarning, stacklevel=<NUM_LIT:8>)<EOL>sort = True<EOL><DEDENT>return _unique_indices(indexes)<EOL><DEDENT><DEDENT>name = _get_consensus_names(indexes)[<NUM_LIT:0>]<EOL>if name != index.name:<EOL><INDENT>index = index._shallow_copy(name=name)<EOL><DEDENT>return index<EOL><DEDENT>else:  <EOL><INDENT>return _unique_indices(indexes)<EOL><DEDENT>
Return the union of indexes.

The behavior of sort and names is not consistent.

Parameters
----------
indexes : list of Index or list objects
sort : bool, default True
    Whether the result index should come out sorted or not.

Returns
-------
Index