#C5269. Sort Books by Dewey Decimal and Title
Sort Books by Dewey Decimal and Title
Sort Books by Dewey Decimal and Title
You are given a list of books where each book is represented by a string in the format title,DDN
, where DDN
is the Dewey Decimal Number. Your task is to sort the books primarily in ascending order of their Dewey Decimal numbers. When two or more books have the same Dewey Decimal number, they should be sorted in alphabetical order based on their titles.
Note: All comparisons on titles are case-sensitive. Ensure that you read from standard input (stdin) and output the result to standard output (stdout).
The sorting criteria can be formally expressed as:
$$\text{{Sort Key}} = \left( \text{{Dewey Decimal Number}}, \text{{Book Title}} \right) $$inputFormat
The first line contains an integer n
, representing the number of books.
The following n
lines each contain a book description in the format title,DDN
, where DDN
is a floating-point number.
outputFormat
Output the sorted book titles, one per line, in the order determined by the sorting criteria.
## sample1
The Great Gatsby,823.912
The Great Gatsby
</p>