I would like to sort SimpleCashFlow(s) according to date. I am having trouble incorporing the the less than function < in std::sort
#include <iostream>
#include <algorithm>
#include <ql/time/date.hpp>
#include <ql/time/period.hpp>
#include <ql/cashflows/simplecashflow.hpp>
using namespace QuantLib;
int main()
{
Date date(1, January, 2021);
Date date2(1, January, 2020);
Real amount = 100.0;
ext::shared_ptr<SimpleCashFlow> cf1(new SimpleCashFlow(amount,date));
ext::shared_ptr<SimpleCashFlow> cf2(new SimpleCashFlow(amount,date2));
Leg leg;
leg.push_back(cf1);
leg.push_back(cf2);
std::sort(leg.begin(),leg.end());
for (auto& c : leg){
std::cout << c->date() << " , " << c->amount() << std::endl;
}
return 0;
}