/
andstorozhok
/
algorithms_python
Обзор
Документация
Войти
/
andstorozhok
/
algorithms_python
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
LSD-MSD sort/lsd_sort.py
27 строк
751 B
bazunaka
Create file for Java
20 сен 2024, 22:48
20 сен 2024, 22:48
69a0e9a
Код
Авторство
О чём код?
def counting_sort(sequince, symbol_position): n = 256 support = [0 for i in range(n)] for element in sequince: support[ord(element[symbol_position])] += 1 size = len(sequince) for i in range(n-1, -1, -1): size -= support[i] support[i] = size result = [None for i in range(len(sequince))] for element in sequince: result[support[ord(element[symbol_position])]] = element support[ord(element[symbol_position])] += 1 return result def radix_sort(sequince): max_len = len(sequince[0]) for i in range(max_len-1, -1, -1): sequince = counting_sort(sequince, i) return sequince sequince = ["cat", "car", "dot", "dog"] result = radix_sort(sequince) print(result)