descending order a list in r

# Create a sample list
my_list <- c(5, 2, 8, 1, 9)

# Use the `order` function to obtain the indices that would sort the list in ascending order
sorted_indices <- order(my_list)

# Use the obtained indices to rearrange the original list in descending order
sorted_list <- my_list[rev(sorted_indices)]