Write bubblesort for R with a variation. This bubblesort should start sorting from the last element first. First describe this algorithm in your own words.
x<-c(21,45,55,67,13,11,2,3,81,44)
example <- function(x){
  n<-length(x)
  for(j in length(x)-1):1){
    for(i in (length(x)-1)){
      if(x[i]>x[i+1]){
        temp<-x[i]
        x[i]<-x[i+1]
        x[i+1]<-temp
      }
    }
  }
  return(x)
}
res<-example(x)
res 
