#K4956. Sort Binary Numbers
Sort Binary Numbers
Sort Binary Numbers
You are given a list of binary number strings. The task is to sort these strings in ascending order based on their decimal values. More formally, for two binary strings \(a\) and \(b\), if \(\text{int}(a,2) < \text{int}(b,2)\), then \(a\) should appear before \(b\) in the sorted order.
The input consists of an integer \(n\) followed by \(n\) lines, each containing a binary string. Your program should output the sorted binary strings, one per line.
Example:
Input: 4 110 10 111 011</p>Output: 10 011 110 111
Remember to read from stdin
and write to stdout
.
inputFormat
The first line of input contains an integer \(n\) (\(1 \leq n \leq 10^5\)), the number of binary strings. The next \(n\) lines each contain a binary string consisting of characters '0' and '1'.
outputFormat
Output the sorted binary strings in ascending order based on their decimal value, each on a separate line.
## sample4
110
10
111
011
10
011
110
111
</p>