title: Python: write dict to csv without changing the order of keys and values?
body: <p>I'm trying to write dict to csv with first column filled with keys, second column filled with values, and only one key/value per row.</p>
  
  <pre><code>import csv
  myDict = {'key1': ['apple', 'kiwi'], 'key2': ['haha','lol'], 'key3': ['meat']}
  
  
  f= open('file.csv', 'w', newline='')
  with open('file.csv', 'w', newline='') as f:
      writer = csv.writer(f,delimiter=',')
      for key, values in myDict.items():
          for value in values:    
              writer.writerow([key, value])
  </code></pre>
  
  <p>The optimal output should be:</p>
  
  <pre><code>key1,apple
  key1,kiwi
  key2,haha
  key2,lol
  key3,meat
  </code></pre>
  
  <p>However when I run the code, it does not always write the keys and values in the order I desire, it writes the keys and values to the csv in a random manner. </p>
  
  <p>(Background: the ordering of the keys and values is an output from previews coding)</p>
  
  <p>Can you please point out what I missed here?
  Thanks in advance!</p>