FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/heap_sort.py at master · caco-can/algorithm · GitHub
caco-can
algorithm
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
heap_sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
13 lines (10 loc) · 252 Bytes
Breadcrumbs
algorithm
/
heap_sort.py
Copy path
File metadata and controls
13 lines (10 loc) · 252 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
#! /usr/bin/evn python
#coding:utf-8
from
heapq
import
*
def
heapsort
(
iterable
):
h
=
[]
for
value
in
iterable
:
heappush
(
h
,
value
)
return
[
heappop
(
h
)
for
i
in
range
(
len
(
h
))]
if
__name__
==
"__main__"
:
print
heapsort
([
1
,
3
,
5
,
9
,
2
])
Back
|
FazBrowse Home
|
New Git URL