Module: Sorting with comparator


Problem

5/11

Sorting an array of structures

Problem

Given a list of people consisting of last name and first name.  Write a program that sorts a list by last name in ascending lexicographic order.
 
Input
First, the number N — the number of people in the list (1<= N <= 100). Next, N names and surnames are written separated by a space.
 
Output
It is necessary to output an array sorted by last name in ascending lexicographic order.

Enter Output
3
Ivan Ivanov
Sidorov Petr
Kurbatov Egor
 
Ivan Ivanov
Kurbatov Egor
Sidorov Petr