0
Names                PRICE        
Sony LED 32          25000
Samsung LED 32       25500
LG LED 32            23000

I want Price column to be sorted in descending order and respective names displayed along its side in the given below manner :-

Samsung LED 32       25500
Sony LED 32          25000
LG LED 32            23000
G5W
  • 32,266
  • 10
  • 31
  • 60

1 Answers1

0

You can get the order of the data using the order function. Then use that to display all fields in that order.

df
           Names PRICE
1    Sony LED 32 25000
2 Samsung LED 32 25500
3      LG LED 32 23000

df[order(df$Names, decreasing = TRUE),]
           Names PRICE
1    Sony LED 32 25000
2 Samsung LED 32 25500
3      LG LED 32 23000

If you want to save it sorted (not just print it) use

df = df[order(df$Names, decreasing = TRUE),]
G5W
  • 32,266
  • 10
  • 31
  • 60