#C13979. Sort Comma Separated Integers

    ID: 43576 Type: Default 1000ms 256MiB

Sort Comma Separated Integers

Sort Comma Separated Integers

Given a string of comma-separated integers, your task is to validate the input and produce a sorted list of these integers in ascending order. The input string may include extra spaces around the commas or numbers. If any non-integer element is encountered, the program should output an error message in exactly the following format:

Error: Input string contains non-numeric elements.

The problem requires strict validation: an empty input or any invalid token (such as alphabetic characters or floating point numbers) should be considered invalid. Use LaTeX to represent any mathematical notation if needed. For example, if the input is a string S, the list of integers is obtained by: \[ \text{List} = \{a_i \in \mathbb{Z} \mid a_i\text{ is parsed from }S\}\] and then sorted in ascending order.

inputFormat

The input is provided as a single line from standard input (stdin). This line contains a string of integers separated by commas. There may be extra spaces before or after the numbers or the commas.

outputFormat

If the input is valid, output the sorted integers in ascending order separated by a single space on one line to standard output (stdout). If the input is invalid (i.e. if the string is empty or any element is not a valid integer), output exactly:

Error: Input string contains non-numeric elements.

## sample
3, 1, 2
1 2 3