Let say I have below dataframe in R
dat = data.frame('col1' = letters[1:10], 'col2' = c('A', 'X', 'D', 'Y', 'A', 'D', 'Y', 'X', 'D', 'A'))
I want to first order this dataframe w.r.t the col2 based on a defined vector c('D', 'Y', 'X', 'A') and then again order based on col1 but in descending order.
Is there any way to achieve this in R?