*blocks your path*
That bubble sort algorithm ain't gonna write itself, sweetie
*blocks your path*
give me a blowjob in my office, bitch
#r8 my pajeetisms, Jow Forums
arr = [7,5,9,1,6,3,10,3]
#change arr at your own will
for i in 1..arr.count-1
if (arr[i-1]>arr[i])
for j in (i).downto(1)
if (arr[j-1]>arr[j])
auxilary=arr[j]
arr[j]=arr[j-1]
arr[j-1]=auxilary
end
end
end
end
puts arr
Quality thread.
arr.bubble_sort()
> Didn’t ask if ascending or descending
You always find something to nitpick about, don't you?
>The bubble sort algorithm is incredibly inefficient and the superior way to sort any list is to use the language's built in sort function
>If you wish to see my actual ability to code I have a hentai cataloging program ported to several different platforms on my github
This isn't OO.
>bubble sort
This one just seems intuitive to me.
//pseudo code
bubble_sort(arr)
{
sorted = False;
while( !sorted )
{
sorted = True;
for(int ii = 0; ii < length(arr) - 1; ii++)
{
if( arr[ii] > arr[ii + 1] )
{
temp = arr[ii];
arr[ii] = arr[ii + 1];
arr[ii + 1] = temp;
sorted = False;
}
}
}
return arr;
}