#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

template <class Container>
void Display(ostream & out, const Container & c);

// Less-than functions

bool IntLessThan(int a, int b)
{ return a > b; }

bool DubLessThan(double a, double b)
{ return a > b; }

int main()
{
  int ints[] = {555, 33, 444, 22, 222, 777, 1, 66};
  vector<int> v(ints, ints + 5);
  sort(v.begin(), v.end(), IntLessThan);
  cout << "\nSorted list of integers:\n";
  Display(cout, v);

  double dubs[] = {55.5, 3.3, 44.4, 2.2, 22.2, 77.7, 0.1};
  deque<double> d(dubs, dubs + 7);
  sort(d.begin(), d.end(), DubLessThan);
  cout << "\nSorted list of doubles:\n";
  Display(cout, d);
}

/* Function template to display elements of any type
 * (for which the output operator is defined) stored
 * in a container c (for which [] and size() are defined)
 * Receive: Type parameter Container
 *          ostream out
 *          Container c
 * Output:  Values stored in c to out
 ************************************************************/

template <class Container>
void Display(ostream & out, const Container & c)
{
  for (int i = 0; i < c.size(); i++)
    out << c[i] << "  ";
  out << endl;
}
