title: Why does overriding __lt__ also change the greater-than operation? Why use it to sort?
body: <p>I am doing leetcode (<a href="https://leetcode.com/problems/largest-number/" rel="nofollow noreferrer">https://leetcode.com/problems/largest-number/</a>)
  and I found the solution in leetcode is :</p>
  <pre><code>class LargerNumKey(str):
      def __lt__(x, y):
          return x+y &gt; y+x
  
  class Solution:    
      def largestNumber(self, nums: List[int]) -&gt; str:
          largest_num = ''.join(sorted(map(str, nums), key=LargerNumKey))
          return '0' if largest_num[0] == '0' else largest_num
  </code></pre>
  <p>I am not sure about why here it overrides <code>__lt__</code> in LargerNumKey. Why not override <code>__gt__</code>?
  And why does the condition in <code>__lt__</code> use <code>x+y &gt; y+x</code>?</p>