samle R code (sorting)