FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
All-Algorithms-In-Python/algorithms/sorting/bucket_sort.py at master · codeme254/All-Algorithms-In-Python · GitHub
codeme254
/
All-Algorithms-In-Python
Public
forked from
AllAlgorithms/python
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
All-Algorithms-In-Python
/
algorithms
/
sorting
/
bucket_sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (22 loc) · 536 Bytes
Breadcrumbs
All-Algorithms-In-Python
/
algorithms
/
sorting
/
bucket_sort.py
Copy path
File metadata and controls
27 lines (22 loc) · 536 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
__author__
=
"Aditya Krishnakumar"
def
bucket_sort
(
A
):
buckets
=
[[]
for
x
in
range
(
10
)]
for
i
,
x
in
enumerate
(
A
):
buckets
[
int
(
x
*
len
(
buckets
))].
append
(
x
)
out
=
[]
for
buck
in
buckets
:
out
+=
isort
(
buck
)
return
out
def
isort
(
A
):
if
len
(
A
)
<=
1
:
return
A
i
=
1
while
i
<
len
(
A
):
k
=
A
[
i
]
j
=
i
-
1
while
j
>=
0
and
A
[
j
]
>
k
:
A
[
j
+
1
]
=
A
[
j
]
A
[
j
]
=
k
j
-=
1
i
+=
1
return
A
Back
|
FazBrowse Home
|
New Git URL