Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Selection sort #205

Merged
merged 5 commits into from
Aug 27, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Basic-Scripts/selection_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def selecsort(lst):
for i in range(len(lst)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use readable variable names instead of alphabets.
Include docstrings for functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

minpos=i
for j in range(i,len(lst)):
if lst[j]<lst[minpos]:
minpos=j
(lst[i],lst[minpos])=(lst[minpos],lst[i])

for item in lst:
print(item)
selecsort([1,5,87,2,-56,89])