#C13093. Flatten and Sort Nested List

    ID: 42593 Type: Default 1000ms 256MiB

Flatten and Sort Nested List

Flatten and Sort Nested List

Given a nested list of integers that may include further nested lists, your task is to flatten the list into a single sequence and then sort the resulting integers in ascending order.

For example, if the input is:

[1, [2, [3, 4]], 5, [6, [7, [8, 9]]]]

then the output should be:

1 2 3 4 5 6 7 8 9

You may assume that the list structure is valid and conforms to JSON list format. Note that an empty list or nested empty lists should result in an empty output.

The sorting condition is defined by the inequality \(a < b\) if and only if integer \(a\) appears before integer \(b\) in the output.

inputFormat

The input is given from standard input as a single line containing a nested list in JSON format. The list can contain integers and/or other nested lists.

Examples of input format:

[5, [3, 9], 1, 7, [2, 8], 6]
[[], [[], []], []]

outputFormat

Output the flattened and sorted list of integers to standard output as a single line. The integers should be separated by a single space. If there are no integers, output an empty line.

## sample
[5, [3, 9], 1, 7, [2, 8], 6]
1 2 3 5 6 7 8 9