title: How to sort multiple columns in R data frame from smallest to largest by group?
body: <p>My data is set out similar to the example below where I have two columns as identifiers (<code>vel</code> and <code>var</code>) and six columns representing difference scores (<code>diff_one</code>, <code>diff_two</code> etc.) which I'd like to arrange from smallest to largest.</p>
  <p>I know I can arrange one column by group as in the case below, but I'd like to arrange/sort all six difference columns from smallest to largest by the grouping variables <code>vel</code> and <code>var</code>. Is there a clean way to do this? Thanks.</p>
  <pre><code>set.seed(10)
  
  dat &lt;- data.frame(
    
    vel = rep(c(&quot;slo&quot;, &quot;med&quot;, &quot;fas&quot;), each = 28),
    var = rep(paste0(&quot;var&quot;, 1:7), times = 12),
    diff_one = rnorm(84, 0.03, 0.08),
    diff_two = rnorm(84, 0.03, 0.08),
    diff_three = rnorm(84, 0.03, 0.08),
    diff_four = rnorm(84, 0.03, 0.08),
    diff_five = rnorm(84, 0.03, 0.08),
    diff_six = rnorm(84, 0.03, 0.08)
    
  )
  
  test &lt;- dat %&gt;%
    filter(vel == &quot;slo&quot;) %&gt;%
    group_by(vel, var) %&gt;%
    arrange(diff_one, .by_group = TRUE)
  </code></pre>