title: how to keep ordered rows in dictionary?
body: <p>I wrote the following script to retrieve the gene count for each contains. It works well but the order of the <code>ID list</code> that I use as an input is not conserved in the output.
  I would need to conserve the same order as my input contigs list is ordered depending on their level of expression
  Can anyone help me?
  Thanks for your help.</p>
  
  <pre><code>from collections import defaultdict
  import numpy as np
  gene_list = {}
  for line in open('idlist.txt'):
      columns = line.strip().split()
      gene = columns[0]
      rien = columns[1]
      gene_list[gene] = rien
  gene_count = defaultdict(lambda: np.zeros(6, dtype=int))
  out_file= open('out.txt','w')
  
  esem_file = open('Aquilonia.txt')
  esem_file.readline()
  for line in esem_file:
      fields = line.strip().split()
      exon = fields[0]
      numbers = [float(field) for field in fields[1:]]
      if exon in gene_list.keys():
           gene = gene_list[exon]
           gene_count[gene] += numbers
           print &gt;&gt; out_file, gene, gene_count[gene]
  
  input file:
  comp54678_c0_seq3
  comp56871_c2_seq8
  comp56466_c0_seq5
  comp57004_c0_seq1
  comp54990_c0_seq11
  ...
  output file comes back in numerical order:
  comp100235_c0_seq1 [22 13 15  6 15 16]
  comp101274_c0_seq1 [55  2 27 26  6  6]
  comp101915_c0_seq1 [20  2 34 12  8  7]
  comp101956_c0_seq1 [13 21 11 17 17 28]
  comp101964_c0_seq1 [30 73 45 36  0  1]
  </code></pre>