Skip to content

Overloading Operator

Sort Operator on Struct

struct Edge
{
    int a, b, w;
    bool operator< (const Edge &t) const
    {
        return w < t.w; // will sort from small to big, aka, increasing order
    }
}e[M];

sort(e, e + m);

Last update: January 9, 2021