nodes: 0, module; 1, function_definition; 2, function_name:_least_constraining_values_sorter; 3, parameters; 4, block; 5, identifier:problem; 6, identifier:assignment; 7, identifier:variable; 8, identifier:domains; 9, expression_statement; 10, comment:# the value that generates less conflicts; 11, function_definition; 12, expression_statement; 13, return_statement; 14, string; 15, function_name:update_assignment; 16, parameters; 17, block; 18, assignment; 19, identifier:values; 20, string_content:Sort values based on how many conflicts they generate if assigned.; 21, identifier:value; 22, expression_statement; 23, expression_statement; 24, return_statement; 25, identifier:values; 26, call; 27, assignment; 28, assignment; 29, identifier:new_assignment; 30, identifier:sorted; 31, argument_list; 32, identifier:new_assignment; 33, call; 34, subscript; 35, identifier:value; 36, subscript; 37, keyword_argument; 38, identifier:deepcopy; 39, argument_list; 40, identifier:new_assignment; 41, identifier:variable; 42, subscript; 43, slice; 44, identifier:key; 45, lambda; 46, identifier:assignment; 47, identifier:domains; 48, identifier:variable; 49, lambda_parameters; 50, call; 51, identifier:v; 52, identifier:_count_conflicts; 53, argument_list; 54, identifier:problem; 55, identifier:assignment; 56, identifier:variable; 57, identifier:v
code: def _least_constraining_values_sorter(problem, assignment, variable, domains):
      '''
      Sort values based on how many conflicts they generate if assigned.
      '''
      # the value that generates less conflicts
      def update_assignment(value):
          new_assignment = deepcopy(assignment)
          new_assignment[variable] = value
          return new_assignment
  
      values = sorted(domains[variable][:],
                      key=lambda v: _count_conflicts(problem, assignment,
                                                     variable, v))
      return values