# How can I sort a data frame by groups? [closed]

I am using R. I have a data frame with "year , price, mileage" columns. I want to group the df by year first and then sort each group by mileage. How can I do this?

• You should consider asking this sort of question over on StackOverflow, not on Data Science. Additionally, you should share what you have already tried in solving this problem. Where exactly did you go wrong? – n1k31t4 Sep 28 '18 at 0:54
• Order by year, mileage? – user2974951 Sep 28 '18 at 6:29

arrange(df, desc(mileage), group_by = year)