title: Python sort to avoid "KeyError: 'href'"
body: <p>I use code as below to sort links:</p>
  
  <pre><code>links = set(soup.findAll('a'))
  links = sorted(links, key=lambda x: x['href'], reverse=True)
  </code></pre>
  
  <p>sometime I got error as this:</p>