#C453. Rearrange Books by Category
Rearrange Books by Category
Rearrange Books by Category
You are given N, the number of books on a shelf, and a list of N integers representing the category of each book. Your task is to rearrange the books such that all books of the same category are grouped together, and these groups are sorted by the category value in ascending order.
Note: The problem simply requires sorting the given list of integers.
Mathematical Formulation:
Given an integer \(N\) and a list \(C = [c_1, c_2, \dots, c_N]\), you need to output a rearranged list \(C'\) where all entries are sorted in non-decreasing order, i.e., \(C' = sort(C)\).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a single integer \(N\), the number of books.
- The second line contains \(N\) integers separated by spaces, representing the categories of the books.
outputFormat
Output to the standard output (stdout) a single line containing the rearranged list of book categories in non-decreasing order, with each number separated by a space.
## sample7
1 2 2 3 1 1 3
1 1 1 2 2 3 3