sort items in array by asc in R
Code snippet on how to sort items in array by asc in R
arr <- c(9, 6, 4, 8, 1, 3)
arr.sort <- sort(arr)
This code uses the sort() method to sort an array, arr, in ascending order. arr is initialized with six numbers in random order. Then, the sort() method is applied to the array, arr, and its sorted result is stored in a new array, arr.sort. The newly sorted array, arr.sort, contains the original array’s numbers in ascending order. This code will create a new array, arr.sort, containing 1, 3, 4, 6, 8, 9.