title: Python: Split a list into smaller jsons based on another list
body: <p>I have one list of program names which need to be sorted into lists of smaller jsons based of a priority list. I need to do this in python 3.
  B and C being of the same priority 2, they will be in a list together.</p>
  
  <pre><code>program_names = ['A','B','C','D']
  priorities = [1,2,2,3]
  </code></pre>
  
  <p>Required end result:</p>
  
  <pre><code>[[{"name": "A"}], [{"name":"B"}, {"name":"C"}], [{"name":"D"}]]
  </code></pre>
  
  <p>Current code:</p>
  
  <pre><code>program_names_list = []
      final_list = []
      for x in program_names.split(','):
          program_names_list.append(x)
      for x in program_names_list:
          final_list.append([{"name": x}])
  </code></pre>
  
  <p>That's what I currently have which is outputting the following result:</p>
  
  <pre><code>[[{'name': 'A'}], [{'name': 'B'}], [{'name': 'C'}], [{'name': 'D'}]]
  </code></pre>
  
  <p>I should add that program_names is a string "A,B,C,D"</p>