OneBite.Dev - Coding blog in a bite size

sort items in array by desc in R

Code snippet on how to sort items in array by desc in R

a <- c(4,3,7,8,12,4,3)
sort(a, decreasing = TRUE)

This code is used to sort items in an array in descending order using the R programming language. The first line creates an array of numbers, which can be changed to any list of numbers that you want to sort. The second line applies the sort() function to the array, with the argument decreasing set to TRUE, which tells the sort() function to sort the list in a descending order. The result is a list of the items, sorted from largest to smallest.

r