Sorting algorithms/Bubble sort: Difference between revisions

Content added Content deleted
m (Categorizing programming examples)
Line 165: Line 165:
x = [3, 78, 4, 23, 6, 8, 6]
x = [3, 78, 4, 23, 6, 8, 6]
bubblesort(x) # [3, 4, 6, 6, 8, 23, 78]
bubblesort(x) # [3, 4, 6, 6, 8, 23, 78]

Python has a built in sort method:
>>> foo = [3, 5, 2, 6, 1]
>>> foo
[3, 5, 2, 6, 1]
>>> foo.sort()
>>> foo
[1, 2, 3, 5, 6]

The built-in sort is not a bubble sort. TODO: I'm not sure what sort the python built-in is, but I'd imagine its fairly efficient.


==[[Ruby]]==
==[[Ruby]]==