Python By Code
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
]
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment