def sort_s(mass):
n = k = 1
while n <= 1000:
for i in range(len(mass) - k):
for j in range(i + 1, len(mass) - k + 1):
if mass[i] // n % 10 > mass[j] // n % 10:
mass[i], mass[j] = mass[j], mass[i]
n *= 10
k += 1
return mass
mass = [int(input('введите элемент массива: ')) for s in range(5)]
print(mass)
print(sort_s(mass))
Объяснение:
def sort_s(mass):
n = k = 1
while n <= 1000:
for i in range(len(mass) - k):
for j in range(i + 1, len(mass) - k + 1):
if mass[i] // n % 10 > mass[j] // n % 10:
mass[i], mass[j] = mass[j], mass[i]
n *= 10
k += 1
return mass
mass = [int(input('введите элемент массива: ')) for s in range(5)]
print(mass)
print(sort_s(mass))
Объяснение: