Having trouble sorting a list with str and int. I want my code to return only listing int in asd and excluding str.
def data(data_list):
for i, n in enumerate(data_list):
mn = min(range(i,len(data_list)), key=data_list.__getitem__)
data_list[i], data_list[mn] = data_list[mn], n
return data_list
data([8,11,10,9,4,3])
#returns this
[3, 4, 8, 9, 10, 11] # which is great but when the list includes str it does not run
#trying to run this
data([8,11,'b',9,4,'a'])
# want to return this
[3, 4, 8, 9]
#Also my code is quite confusing. I am sure there is a simpler way
sortedfunction, andsortmethod of lists, are built-in. You do not need to implement sorting logic yourself.