isLessThan function for structure with 7 integers The objective

I was trying to create a function that would compare 7 different integers. It should be able to be used to:


Sort the two structures in a consistent manner
Be able to detect if two structures are equal with !isLessThan(a,b) &amp;&amp; !isLessThan(b,a)


The code

At first, I thought of using a hash function to reduce all the values to one, but then it occurred to me that I was over-engineering this simple problem.

This is language agnostic, but I ended up doing it like this:

bool isLessThan(const MyStruct&amp; lhs, const MyStruct&amp; rhs) {
    return
        lhs.a +
        lhs.b * 2 +
        lhs.c * 3 +
        lhs.d * 4 +
        lhs.e * 5 +
        lhs.f * 6 +
        lhs.g * 7
            &lt;
        rhs.a +
        rhs.b * 2 +
        rhs.c * 3 +
        rhs.d * 4 +
        rhs.e * 5 +
        rhs.f * 6 +
        rhs.g * 7;
}
Don't re-invent the wheel (unless of course you want practice at doing that):


Instead of naming a bunch of elements that are all the same type, use an array for your structure's elements like std::array, or use a std::tuple. Or if you really don't want to change your structure's content, use std::tie to craft a tuple of your structure's elements on demand.
If you used a regular array use std::lexicographical_compare on the iterable elements of the two structures. A std::array or std::tuple already has non-member function support for operators like &lt;, &lt;=, &gt;=, etc. though. 
Kick back and enjoy a brewski. ;)  (only if allowed of course and be sure to drink responsibly etc. etc.).