R Function Sort Dataframe By Index