title: How to sort results in ggplot according to grouping variable
body: <p>I create a bar chart, with each bar colored according to what group it belongs to, using the following code.</p>
  
  <pre><code>library("ggplot2")
  df &lt;- data.frame(ID=c(5,2,3,6,1,4),Score=c(24.8,33.2,55.21,19.21,41.99,15.23),Gender=c("Man","Woman","Woman","Man","Man","Woman"))
  ggplot(df, aes(x=ID, y=Score, color=Gender)) + geom_bar(stat="identity")
  </code></pre>
  
  <p>This generates the following graph</p>
  
  <p><img src="https://i.stack.imgur.com/F0QVN.png" alt="enter image description here"></p>
  
  <p>Now, what I'd like to achieve is to sort the order in which the bars appear, primary on the gender variable and secondary on the ID variable. I've searched for answers here on StackExchange, but from what I can tell, most of them deals with sorting on the y variable only.</p>
  
  <p>(Note that this is a minimal example and my real example is pretty huge. Therefore, I'd like to find a way to order everything where I don't have to, for example, type in every ID number manually.)</p>