2016-07-19 22:34:17 +05:30
|
|
|
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
|
|
|
|
|
|
2016-07-28 22:33:24 +05:30
|
|
|
aList = swap( aList, least, i )
|
|
|
|
|
print(aList)
|
2016-07-19 22:34:17 +05:30
|
|
|
|
|
|
|
|
def swap( A, x, y ):
|
|
|
|
|
tmp = A[x]
|
|
|
|
|
A[x] = A[y]
|
|
|
|
|
A[y] = tmp
|
2016-07-28 22:33:24 +05:30
|
|
|
return A
|
|
|
|
|
|
|
|
|
|
print ("Enter numbers seprated by comma ")
|
|
|
|
|
response = input()
|
|
|
|
|
aList = list(response.split(','))
|
|
|
|
|
selectionsort(aList)
|