Sorting has been discussed quite a bit here, but I have a particular problem. I have a data frame (df) with several columns. All the observations belong to one of three types, say C1, C2, and C3. Of the various columns, one contains a value which I will call frequency (f). Example df:
Type freq Val
C3. 0.34. 10-A
C1. 0.90. 4-A
C2. 0.40. 5-B
C1. 0.65. 3-C
C2. 0.77. 5-D
C3. 0.11. 5-D
I need to sort this table so that the primary key is the Type, and secondary key is the frequency. However, and here’s my problem, they need to be sorted by a particular order of type. I need them by C1, C3, C2. So the final table looks like this:
Type freq Val
C1. 0.90. 4-A
C1. 0.65. 3-C
C3. 0.34. 10-A
C3. 0.11. 5-D
C2. 0.77. 5-D
C2. 0.40. 5-B
Is there a way to do this? To pick the particular ordering scheme of the column Type. Any suggestion is much appreciated. Thanks