I am trying to sort the options in a select list alphabetically using Jinja filters. the problem I am having is the list has mixed case values and it is not coming out alphabetically. I would still like to continue using the jinja filter wondering if anyway to make it compare by lower case or something.
The list in its current form
- All Source Types
- Android Market
- Forums
- RSS Feeds
- YouTube
- iTunes
Jinja Code
{% for source,number in sources.items()|sort %}
<option {% if number == user.postfiltertype %} selected {% endif %} value='{{ number }}'>{{ source }}</option>
{% endfor %}
Input
[('iTunes', 8), ('RSS Feeds', 2), ('Twitter Incoming', 9), ('Facebook', 4), ('Android Market', 10), ('All Source Types', 0), ('YouTube', 5), ('Twitter', 3), ('Forums', 1)]
You can add the following after
|sort:So you get:
See:
http://jinja.pocoo.org/docs/templates/#filters