How to define the sort order of a dataframe?
<p>I would like to sort a dataframe based on week number, and day of the week.</p>

<p>Week number variable is a double.</p>

<p>Day of the week is a text (Mon, Tue, Wed, Thu, Fri, Sat, Sun).  </p>

<p>Here is my dataframe:</p>

<pre><code>week_number  |  day_of_week  |  job_count  | eff_rate
-----------------------------------------------------
1            | Fri           |  30         |  70
1            | Mon           |  50         |  80       
1            | Sat           |  340        |  20
1            | Sun           |  1          |  8
1            | Thu           |  3          |  40
1            | Tue           |  4          |  10
1            | Wed           |  50         |  70
2            | Fri           |  120        |  180
2            | Mon           |  12         |  80
2            | Sat           |  11         |  9
2            | Sun           |  80         |  11
2            | Tue           |  60         |  14
2            | Thu           |  4          |  23
2            | Wed           |  1          |  50
</code></pre>

<p>I think that I would need to define a function where I define how the sort should order the content of the variable.  Let's say the function is called manualsort.  What would manualsort() look like such that it can be used like this?</p>

<pre><code> df.sort(asc("week_number"), manualsort("day_of_week"))
</code></pre>

<p>The outcome would be something like this:</p>

<pre><code>week_number  |  day_of_week  |  job_count  | eff_rate
-----------------------------------------------------
1            | Mon           |  50         |  80
1            | Tue           |  4          |  10       
1            | Wed           |  50         |  70
1            | Thu           |  3          |  40
1            | Fri           |  120        |  180
1            | Sat           |  340        |  20
1            | Sun           |  1          |  8
</code></pre>