Complex sorting of an array of structures
Problem
Given a list of people consisting of last name and first name. Write a program that sorts the list by last name in ascending lexicographic order. If the last names match, then sort by first name.
Input
First given a number N
- number of people in the list (1<= N <= 100). Next, N
surnames and first names are written with a space.
Output
It is necessary to output an array sorted by last name in ascending lexicographic order, if the last name matches, sort by first name.
Examples
# |
Input |
Output |
1 |
3
Sidorov Petr
Ivan Ivanov
Ivanov Anton |
Ivanov Anton
Ivan Ivanov
Sidorov Petr
|