You can also use the arrange function of the dplyr package, which I particularly find easier in both reading and writing than the "normal" p>
I highly recommend learning the dplyr package for manipulating data in a dataframe.
Just enter the dataframe and columns in order of sorting
v1 <- c(1,4,1,5,4,1)
v2 <- c(5,1,2,7,2,9)
grupo <- c(1,1,1,2,2,2)
df <- data.frame(v1,v2,grupo)
library(dplyr)
arrange(df, grupo, v2)
# v1 v2 grupo
# 4 1 1
# 1 2 1
# 1 5 1
# 4 2 2
# 5 7 2
# 1 9 2
If you want something in descending order, for example v2, use desc (nameColumn):
arrange(df, grupo, desc(v2))
# v1 v2 grupo
# 1 5 1
# 1 2 1
# 4 1 1
# 1 9 2
# 5 7 2
# 4 2 2