mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Improvement
This commit is contained in:
parent
d44b888aeb
commit
c5c2fa3b9d
|
@ -1,4 +1,3 @@
|
||||||
print ("Enter numbers seprated by comma ")
|
|
||||||
def selectionsort( aList ):
|
def selectionsort( aList ):
|
||||||
for i in range( len( aList ) ):
|
for i in range( len( aList ) ):
|
||||||
least = i
|
least = i
|
||||||
|
@ -6,9 +5,16 @@ def selectionsort( aList ):
|
||||||
if aList[k] < aList[least]:
|
if aList[k] < aList[least]:
|
||||||
least = k
|
least = k
|
||||||
|
|
||||||
swap( aList, least, i )
|
aList = swap( aList, least, i )
|
||||||
|
print(aList)
|
||||||
|
|
||||||
def swap( A, x, y ):
|
def swap( A, x, y ):
|
||||||
tmp = A[x]
|
tmp = A[x]
|
||||||
A[x] = A[y]
|
A[x] = A[y]
|
||||||
A[y] = tmp
|
A[y] = tmp
|
||||||
|
return A
|
||||||
|
|
||||||
|
print ("Enter numbers seprated by comma ")
|
||||||
|
response = input()
|
||||||
|
aList = list(response.split(','))
|
||||||
|
selectionsort(aList)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user