#C14614. Filter and Sort Numbers
Filter and Sort Numbers
Filter and Sort Numbers
Given a list of tokens, where each token is either an integer or a string, your task is to filter out any token that does not represent a valid integer, convert the valid ones to integers, and then output the sorted list in ascending order.
You should consider negative numbers and handle duplicates. The goal is to obtain a sorted output S such that:
$$ S = \text{sorted}\Big(\{ x \in \mathbb{Z} \mid x = \text{int}(s) \text{ for each valid token } s \}\Big) $$
If there are no valid integers in the input, output an empty line.
inputFormat
The input is provided via standard input (stdin) as a single line containing space-separated tokens. Each token may be either an integer or a string.
outputFormat
Print the sorted list of integers separated by a single space to standard output (stdout). If no valid integer exists, print an empty line.
## sample5 3 1 a 2 4
1 2 3 4 5