I have an index-of-a-book-like list of lines, say
day satur- sun- holy- night ball to- eve election christmas
Now I want to sort these lines in the obvious fashion: I want to group every “parent”-entry (
eve) with their respective indented “child”-entries (
sun-, …) and sort these groups by their parent-entry. I also want to sort the child-entries within any given group.
Thus, the desired output is:
day holy- satur- sun- eve christmas election night ball to-
How would I best achieve this by using unix core tools like