Assumes list items are unique

    Args:
        list1 (list): a list of unique items to be aligned
        list2 (list): a list of unique items in a desired ordering
        missing (bool): True if list2 can contain items not in list1

    Returns:
        list: sorting that will map list1 onto list2

    CommandLine:
        python -m utool.util_list list_alignment

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> list1 = ['b', 'c', 'a']
        >>> list2 = ['a', 'b', 'c']
        >>> sortx = list_alignment(list1, list2)
        >>> list1_aligned = take(list1, sortx)
        >>> assert list1_aligned == list2

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> list1 = ['b', 'c', 'a']
        >>> list2 = ['a', 'a2', 'b', 'c', 'd']
        >>> sortx = ut.list_alignment(list1, list2, missing=True)
        >>> print('sortx = %r' % (sortx,))
        >>> list1_aligned = ut.none_take(list1, sortx)
        >>> result = ('list1_aligned = %s' % (ut.repr2(list1_aligned),))
        >>> print(result)
        list1_aligned = ['a', None, 'b', 'c', None]

def list_alignment(list1, list2, missing=False):
    """
    Assumes list items are unique

    Args:
        list1 (list): a list of unique items to be aligned
        list2 (list): a list of unique items in a desired ordering
        missing (bool): True if list2 can contain items not in list1

    Returns:
        list: sorting that will map list1 onto list2

    CommandLine:
        python -m utool.util_list list_alignment

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> list1 = ['b', 'c', 'a']
        >>> list2 = ['a', 'b', 'c']
        >>> sortx = list_alignment(list1, list2)
        >>> list1_aligned = take(list1, sortx)
        >>> assert list1_aligned == list2

    Example1:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> list1 = ['b', 'c', 'a']
        >>> list2 = ['a', 'a2', 'b', 'c', 'd']
        >>> sortx = ut.list_alignment(list1, list2, missing=True)
        >>> print('sortx = %r' % (sortx,))
        >>> list1_aligned = ut.none_take(list1, sortx)
        >>> result = ('list1_aligned = %s' % (ut.repr2(list1_aligned),))
        >>> print(result)
        list1_aligned = ['a', None, 'b', 'c', None]
    """
    import utool as ut
    item1_to_idx = make_index_lookup(list1)
    if missing:
        sortx = ut.dict_take(item1_to_idx, list2, None)
    else:
        sortx = ut.take(item1_to_idx, list2)
    return sortx