title: sort in jinja2 when attribute is not available
body: <p>I have a set of articles (using <a href="https://github.com/getpelican" rel="nofollow">pelican</a> for generating static sites) which includes a category called hotels. I'd like to sort these hotels. The problem is that only the hotels have an attribute called 'city' while the other articles do not and this obviously leads to the following error:</p>
  
  <pre><code>Caught exception "'pelican.contents.Article object' has no attribute 'city'".
  </code></pre>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>{% for article in articles|sort(attribute='city') %}
  {% if article.category == 'hotels' %}
      &lt;a href="hotels/{{ article.slug }}.html"&gt;
      &lt;p&gt;{{ article.title }}&lt;/p&gt;
      &lt;/a&gt;
  {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Is there a way to check to see if the attribute exists and provide some default value so that it does not cause an error?</p>