how to order a dataframe by rank