#C71. Sorting Book Titles

    ID: 50933 Type: Default 1000ms 256MiB

Sorting Book Titles

Sorting Book Titles

Given a list of book titles, your task is to sort them according to the following rules:

  • Book titles containing the substring Python should be sorted in reverse alphabetical order.
  • Book titles that do not contain Python should be sorted in normal alphabetical order.

After sorting, first output the Python-related titles followed by the remaining titles. For example, if the input list is:

Beginning Python
Advanced Machine Learning
Python Cookbook
Data Science from Scratch
Effective Python

then the expected output will be:

Python Cookbook
Effective Python
Beginning Python
Advanced Machine Learning
Data Science from Scratch

Please note that the sorted order for titles containing Python is determined by comparing strings in reverse lexicographical (alphabetical) order, and the rest are compared in normal alphabetical order.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 100), representing the number of book titles. The following n lines each contain a single book title.

outputFormat

Output the sorted list of book titles, each on a new line. First output the titles containing Python (sorted in reverse alphabetical order), followed by the other titles (sorted in normal alphabetical order).

## sample
5
Beginning Python
Advanced Machine Learning
Python Cookbook
Data Science from Scratch
Effective Python
Python Cookbook

Effective Python Beginning Python Advanced Machine Learning Data Science from Scratch

</p>