A job sequencing solution I have written this code as a college assignment fot the famous job sequencing problem. Please tell me any improvements if possible. Oh, for algorithms.h header file, refer my github repo 

The code: 

#include "algorithms.h"

struct Job {
    int index = 0;
    int time_slot = 0;
    int profit = 0;
public:
    Job() = delete;
    explicit Job(int i, int time, int pr) {
        index = i;
        time_slot = time;
        profit = pr;
    }
    bool operator&gt;=(Job j) {
        if ((this-&gt;time_slot == j.time_slot &amp;&amp; this-&gt;profit &gt;= j.profit) || (this-&gt;time_slot &gt; j.time_slot)) {
            return true;
        }
        return false;
    }
    bool operator&lt;=(Job j) {
        if ((this-&gt;time_slot == j.time_slot &amp;&amp; this-&gt;profit &lt;= j.profit) || (this-&gt;time_slot &lt; j.time_slot)) {
            return true;
        }
        return false;
    }
    bool operator&lt;(Job j) {
        if ((this-&gt;time_slot == j.time_slot &amp;&amp; this-&gt;profit &lt; j.profit) || (this-&gt;time_slot &lt; j.time_slot)) {
            return true;
        }
        return false;
    }
    bool operator&gt;(Job j) {
        if ((this-&gt;time_slot == j.time_slot &amp;&amp; this-&gt;profit &gt; j.profit) || (this-&gt;time_slot &lt; j.time_slot)) {
            return true;
        }
        return false;
    }
    bool operator==(Job j) {
        if (this-&gt;time_slot == j.time_slot) {
            return true;
        }
        return false;
    }
    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, Job job) {
        out &lt;&lt; job.index;
        return out;
    }
};

int main() {
    Job j1(1, 1, 3);
    Job j2(2, 3, 5);
    Job j3(3, 4, 20);
    Job j4(4, 3, 18);
    Job j5(5, 2, 1);
    Job j6(6, 1, 6);
    Job j7(7, 2, 30);
    std::vector&lt;Job&gt; vect = { j1,j2,j3,j4,j5,j6,j7 };
    vect = Sorter&lt;Job&gt;::mergeSort(vect);
    auto order = [&amp;]() {
        auto it = vect.begin();
        while (it + 1 != vect.end()) {
            if (*it == *(it + 1)) {
                it = vect.erase(it);
                continue;
            }
            it++;
        }
    };
    order();
    std::for_each(vect.begin(), vect.end(), [](Job i) {std::cout &lt;&lt; i &lt;&lt; " "; });
    return 0;
}
The Job class has public members, so it's simpler to make it an aggregate:

struct Job {
    int index;
    int time_slot;
    int profit;
};


Then, use std::tie to simplify the comparison operators: (operands to these operators should be marked as const, which you didn't)

bool operator&lt;(const Job&amp; lhs, const Job&amp; rhs)
{
    return std::tie(lhs.time_slot, lhs.profit) &lt; std::tie(rhs.time_slot, rhs.profit);
}

// implement other operators in terms of &lt;


You == is not consistent with other comparison operators, which is confusing and likely to cause problems.

Also note that if (condition) { return true; } return false; should be changed to return condition; for clarity.

This is convoluted:


Job j1(1, 1, 3);
Job j2(2, 3, 5);
Job j3(3, 4, 20);
Job j4(4, 3, 18);
Job j5(5, 2, 1);
Job j6(6, 1, 6);
Job j7(7, 2, 30);
std::vector&lt;Job&gt; vect = { j1,j2,j3,j4,j5,j6,j7 };



It should be simplified to

std::vector&lt;Job&gt; vect {
    {1, 1, 3}, {2, 3, 5}, // ...
};


This:


auto order = [&amp;]() {
    auto it = vect.begin();
    while (it + 1 != vect.end()) {
        if (*it == *(it + 1)) {
            it = vect.erase(it);
            continue;
        }
        it++;
    }
};
order();



should be

vect.erase(std::unique(vect.begin(), vect.end()), vect.end());


(provided that I understand the code correctly).

And this:


std::for_each(vect.begin(), vect.end(), [](Job i) {std::cout &lt;&lt; i &lt;&lt; " "; });



is a complicated way of writing

for (const auto&amp; job : vect) {
    std::cout &lt;&lt; job &lt;&lt; ' ';
}


or

std::copy(vect.begin(), vect.end(),
          std::ostream_iterator&lt;Job&gt;{std::cout, ' '});