order returns row positions in sorted order. Data frames use those positions to rearrange rows.

Program

Play the script to rank rows by points and choose the winner.

ordering.R
scores <- data.frame(name = c("Ada", "Lin", "Mia"), points = c(9, 12, 10))
ranked <- scores[order(scores$points, decreasing = TRUE), ]
winner <- ranked$name[1]
cat(winner, "\n", sep = "")
order `order(scores$points)` returns row positions sorted by points.
decreasing `decreasing = TRUE` sorts highest values first.
row subset `scores[rows, ]` reorders the rows and keeps every column.