nodes: 0, module; 1, function_definition; 2, function_name:list_alignment; 3, parameters; 4, block; 5, identifier:list1; 6, identifier:list2; 7, default_parameter; 8, expression_statement; 9, import_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:missing; 14, False; 15, comment:"""
      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]
      """; 16, aliased_import; 17, assignment; 18, identifier:missing; 19, block; 20, else_clause; 21, identifier:sortx; 22, dotted_name; 23, identifier:ut; 24, identifier:item1_to_idx; 25, call; 26, expression_statement; 27, block; 28, identifier:utool; 29, identifier:make_index_lookup; 30, argument_list; 31, assignment; 32, expression_statement; 33, identifier:list1; 34, identifier:sortx; 35, call; 36, assignment; 37, attribute; 38, argument_list; 39, identifier:sortx; 40, call; 41, identifier:ut; 42, identifier:dict_take; 43, identifier:item1_to_idx; 44, identifier:list2; 45, None; 46, attribute; 47, argument_list; 48, identifier:ut; 49, identifier:take; 50, identifier:item1_to_idx; 51, identifier:list2
code: 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