title: Custom sorting (non-alphabetical)
body: <p>I have a categorical data set that looks similar to:</p>
  
  <pre><code>A &lt; -data.frame(animal = c("cat","cat","cat","dog","dog","dog","elephant","elephant","elephant"),
                  color = c(rep(c("blue","red","green"), 3)))
  
      animal color
  1      cat  blue
  2      cat   red
  3      cat green
  4      dog  blue
  5      dog   red
  6      dog green
  7 elephant  blue
  8 elephant   red
  9 elephant green
  </code></pre>
  
  <p>I want to order it so that 'animal' is sorted as <code>dog &lt; elephant &lt; cat</code>, and then the color is sorted <code>green &lt; blue &lt; red</code>.  So in the end it would look like</p>
  
  <pre><code>#     animal color
  # 6      dog green
  # 4      dog  blue
  # 5      dog   red
  # 9 elephant green
  # 7 elephant  blue
  # 8 elephant   red
  # 3      cat green
  # 1      cat  blue
  # 2      cat   red
  </code></pre>