Python By Code
Showing posts with label
Bubble sort
.
Show all posts
Showing posts with label
Bubble sort
.
Show all posts
Friday, September 11, 2015
Bubble sort in Python
def
bubble_sort
(
items
):
""" Implementation of bubble sort """
for
i
in
range
(
len
(
items
)):
for
j
in
range
(
len
(
items
)
-
1
-
i
):
if
items
[
j
]
>
items
[
j
+
1
]:
items
[
j
],
items
[
j
+
1
]
=
items
[
j
+
1
],
items
[
j
]
Older Posts
Home
Subscribe to:
Posts (Atom)