mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Changed extention of previous files and added Selection sort
This commit is contained in:
parent
5e3a0d49d0
commit
b1b4bdaecd
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
array=[];
|
||||
|
||||
# input
|
14
SelectionSort.py
Normal file
14
SelectionSort.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
print ("Enter numbers seprated by comma ")
|
||||
def selectionsort( aList ):
|
||||
for i in range( len( aList ) ):
|
||||
least = i
|
||||
for k in range( i + 1 , len( aList ) ):
|
||||
if aList[k] < aList[least]:
|
||||
least = k
|
||||
|
||||
swap( aList, least, i )
|
||||
|
||||
def swap( A, x, y ):
|
||||
tmp = A[x]
|
||||
A[x] = A[y]
|
||||
A[y] = tmp
|
Loading…
Reference in New Issue
Block a user