In R, you can sort an array using the sort()
function. By default, the function sorts the array in ascending order.
Here is an example code to sort an array in R:
main.r155 chars9 lines
Output:
main.r22 chars2 lines
In this example, the array arr
is created using the array()
function with a vector of elements and dimensions of 3 rows and 3 columns. The sort()
function is used to sort the array in ascending order, and the resulting sorted array is stored in sorted_arr
. Finally, the sorted array is printed to the console.
gistlibby LogSnag