<p>I should start by saying I have solved this problem, but I feel like my code is ugly and overkill.</p>

<p>I am trying to sort a dataframe on a column containing human chromosomes:</p>

<p>chr1,chr2...chrY, chrX.</p>

<p>the problem is:</p>

<p>chr1, is followed by chr10.  </p>

<p>What tricks do you use to deal with this problem <strong>IN the [R] environment?</strong></p>

<p>Hi Zev, </p>
<p>what you are looking for is: <a href="http://rss.acs.unt.edu/Rdoc/library/gtools/html/mixedsort.html">mixedsort {gtools}</a></p>
<blockquote>
<p>Order or Sort strings with embedded numbers so that the numbers are in the correct order</p>
</blockquote>
<pre><code>package 'gtools' was built under R version 2.13.2

n&lt;- c('chr1','chr21','chr13','chr4','chr10')
&gt; n
[1] "chr1"  "chr21"   "chr13"   "chr4"   "chr10"

&gt; mixedsort(n)
[1] "chr1"     "chr4"   "chr10"     "chr13"   "chr21"
</code></pre>
<p>I hope this helps.</p>