Sort file tree paths
A code review tool draws the file tree of a changeset. entries holds one path per touched item, and a directory always ends with a slash while a file never does. Return the same entries in the order the tree draws them. Order by path segments, splitting each path on the slash, rather than by the raw string. Segments compare as ordinary text, character by character, so capitals come before lowercase and 'v10' comes before 'v2'. When one path's segments are the leading segments of another, the shorter path comes first, which is what puts a directory immediately ahead of everything inside it. No name is both a file and a directory, so exactly one order satisfies the rule. An empty changeset returns an empty list.
order_tree_entries(entries: list[str]) → list[str][["src.md","src/","src/app.ts","src/app/","src/app/main.ts","README.md"]]out["README.md","src/","src/app/","src/app/main.ts","src/app.ts","src.md"][["docs/guide.md","docs/","docs/api/","docs/api/v1.md","LICENSE"]]out["LICENSE","docs/","docs/api/","docs/api/v1.md","docs/guide.md"]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["src.md","src/","src/app.ts","src/app/","src/app/main.ts","README.md"]]["README.md","src/","src/app/","src/app/main.ts","src/app.ts","src.md"]not run yetsample[["docs/guide.md","docs/","docs/api/","docs/api/v1.md","LICENSE"]]["LICENSE","docs/","docs/api/","docs/api/v1.md","docs/guide.md"]not run yetsample