I would like to sort (and rearrange) columns in a tibble object. The table (let's call it dataSet) that I am working with looks like this:
| Fall 2019 | Fall 2020 | Spring 2019 | Spring 2020 | Spring 2021 |
|---|---|---|---|---|
| 1 | 36 | 32 | 43 | 25 |
| 15 | 84 | 94 | 64 | 65 |
I would like to have it sorted in the following order.
| Spring 2019 | Fall 2019 | Spring 2020 | Fall 2020 | Spring 2021 |
|---|---|---|---|---|
| 32 | 1 | 43 | 36 | 25 |
| 94 | 15 | 64 | 84 | 65 |
Since the columns are essentially strings, I have tried using str_sort(names(dataSet)). However, this returns the original column names as it is already sorted. If I can get the column's name sorted, I know I can rearrange the columns in the tibble object. I've worked with time objects before, but those are usually for formats like mm/dd/yyyy, but nothing in terms of semesters. Any help will be greatly appreciated. Thanks in advance!