title: Creating 3-way tables: tabyl output sorting
body: <p>I am trying to create a three-way tabyl and I am struggling to sort the columns and rows as I want. Here is the example:</p>
  
  <pre><code>library(janitor)
  df &lt;- data.frame(gender = c("f", "m", "m", "f", "m"),
                   age_group = factor(
                     c("35-45", "18-35", "&gt;55", "45-55", "&gt;55"), 
                     levels = c("18-35", "35-45", "45-55", "&gt;55")),
                   bmi_group = factor(
                     c("18.5 - 25", "&lt;18.5", "18.5 - 25", "&gt;30", "25 - 30"),
                     levels = c("&lt;18.5", "18.5 - 25", "25 - 30", "&gt;30")),
                   stringsAsFactors = TRUE)
  
  
  df %&gt;%
    tabyl(bmi_group, age_group, gender, show_missing_levels = FALSE) %&gt;%
    adorn_totals("row") %&gt;%
    adorn_percentages("all") %&gt;%
    adorn_pct_formatting(digits = 1) %&gt;%
    adorn_ns %&gt;%
    adorn_title
  </code></pre>
  
  <p>It gives me this:</p>
  
  <p><a href="https://i.stack.imgur.com/btvzQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/btvzQ.png" alt="enter image description here"></a></p>
  
  <p>I can't figure out how to sort entries in gender-specific tables by factor levels. The sorting is alphabetical right now.</p>