title: Sort sequence in order from FASTA file by python program
body: <p>I was trying to create a python program that reads the fasta file "seqs.fa"
  and have the program to sort the sequences in order by the name.</p>
  
  <p>The Fasta file looks like this:</p>
  
  <pre><code>&gt;seqA - human
  GCTGACGTGGTGAAGTCAC
  &gt;seqC - gorilla
  GATGACAA
  GATGAAGTCAG
  &gt;seqB - chimp
  GATGACATGGTGAAGTAAC
  </code></pre>
  
  <p>My program looks like this:</p>
  
  <pre><code>import sys
  
  inFile = open(sys.argv[1], 'r')
  a = inFile.readlines()
  a.sort()
  seq = ''.join(a[0:])
  seq = seq.replace('\n', "\n")
  print seq
  </code></pre>
  
  <p>The expected result:</p>
  
  <pre><code>&gt;seqA - human
  GCTGACGTGGTGAAGTCAC
  &gt;seqB - chimp
  GATGACATGGTGAAGTAAC
  &gt;seqC - gorilla
  GATGACAAGATGAAGTCAG
  </code></pre>
  
  <p>My result:</p>
  
  <pre><code>&gt;seqA - human
  &gt;seqB - chimp
  &gt;seqC - gorilla
  GATGACAA
  GATGAAGTCAG
  GATGACATGGTGAAGTAAC
  GCTGACGTGGTGAAGTCAC
  </code></pre>
  
  <p>The last four lines are the gorilla, chimp, and human sequences, with the gorilla sequence split over the first two lines. </p>
  
  <p>Can anyone give me some tips on how to sort it or a way to fix the problem?</p>