Дано відповідність між предметами та предметами, від яких вони залежать, типологічне сортування розпоряджається предметами так, що жоден предмет не перевершує предмет, від якого залежить. Існує два популярних алгоритми для типологічного сортування: типологічне сортування Кана (1962) та пошук у глибину.
# --instructions--
Створіть функцію, яка поверне список допустимого компільованого порядку бібліотек з їх залежностями.
- Допустимо, що назви бібліотек складаються з одного слова.
- Елементи, вказані як лише залежні не мають власних залежностей, але їх порядок компіляції повинен бути вказаний.
- Будь-які власні залежності слід ігнорувати.
- Будь-які невпорядковані залежності слід ігнорувати.
Компілювання бібліотеки мовою VHDL має обмеження: бібліотеку потрібно скомпілювати після будь-якої бібліотеки, від якої вона залежить. Наведені вище дані будуть невпорядковані, якщо, наприклад, `dw04` додано до списку залежностей `dw01`.
Вхідним значенням функції буде багаторядковий рядок, кожен рядок міститиме назву бібліотеки з її залежностями (якщо існують).
Наприклад:
```js
const libsSimple =
`aaa bbb
bbb`;
```
# --hints--
`topologicalSort` має бути функцією.
```js
assert(typeof topologicalSort === 'function');
```
`topologicalSort(libsSimple)` має повернути масив.