What is the best way to implement operator<?
<p>Sorry if this is a stupid question, but it's something that I'm curious about.</p>

<p>I am overloading the less-than operator for my sort algorithm based on last name, first name, middle name. I realize there is not a right or wrong here, but I'm curious as to which style is written better or preferred among fellow programmers.</p>

<pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const
{
    if (m_Last &lt; key.m_Last)
        || ( (m_Last == key.m_Last) &amp;&amp; (m_First &lt; key.m_First) )
        || ( (m_Last == key.m_Last) &amp;&amp; (m_First == key.m_First) &amp;&amp; (m_Middle &lt; key.m_Middle) )
        return true;
    return false;
}
</code></pre>

<p>or</p>

<pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const
{
    if (m_Last &lt; key.m_Last)
        return true;
    else if ( (m_Last == key.m_Last) &amp;&amp; (m_First &lt; key.m_First) )
        return true;
    else if ( (m_Last == key.m_Last) &amp;&amp; (m_First == key.m_First) &amp;&amp; (m_Middle &lt; key.m_Middle) )
        return true;
    else
        return false;
}
</code></pre>

<p>or</p>

<pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const
{
    if (m_Last &lt; key.m_Last)
        return true;

    if (m_Last == key.m_Last)
        if (m_First &lt; key.m_First)
            return true;

    if (m_Last == key.m_Last)
        if (m_First == key.m_First)
            if (m_Middle &lt; key.m_Middle)
                return true;

    return false;
}
</code></pre>
