title: Sort by variable in twoway scatter. X-axis stays alphabetical and sort produces gibberish: why?
body: <p>I have two variables: </p>
  
  <pre><code>ie_ctotal
  cntry2
  </code></pre>
  
  <p>Note: <code>cntry2</code> is an <code>encode</code>d version of a string variable <code>cntry</code>: I don't know if this may be affecting things. </p>
  
  <p>I want a <code>twoway scatter</code> of <code>ie_ctotal</code> and <code>cntry2</code>, and I want to SORT this scatter by another variable <code>gdppc</code>,</p>
  
  <pre><code> twoway  || scatter ie_ctotal cntry2, c(1) xlabel(,valuelabel)
  </code></pre>
  
  <p>The above without <code>sort</code> works fine. Once I introduce <code>sort</code>, however, </p>
  
  <pre><code> twoway  || scatter ie_ctotal cntry2, c(1) sort(gdppc) xlabel(,valuelabel)
  </code></pre>
  
  <p>The graph turns gibberish, or rather it connects according to the <code>sort</code>, but the x axis remains alphabetical, making the connections seem scribbled.</p>
  
  <p>Any ideas as to what I am doing wrong?</p>
  
  <p>Note: I don't want to <code>sort</code> the original data, because I was advised in previous questions that this is a bad idea. So I want to <code>sort</code> the data only for this one graph.</p>