Module: Sorting with comparator


Problem

6/11

Sorting a vector through a function object

Theory Click to read/hide

you can also specify a function object as a comparator, which you can create before calling the sort function.
For example:

struct {
        bool operator()(int a, int b) const
        {
            return a < b;
        }
    }cmp;

Problem

You are given a sequence of integers. Write a program that creates and sorts an array in descending order.
 
Input
First given number N — the number of elements in the array (1<=N<=100). Further, through the space, N numbers are written — array elements. The array consists of integers.
 
Output
It is necessary to output an array sorted in descending order.
 
Input Output
5
4 56 23 67 100
100 67 56 23 4