How do I output entries by their category? Ok, so basically I want to loop through categories and output the title of each category along with all the associated entries. Like so:

Category 1: Entry 1 Title, Entry 3 Title

Category 2: Entry 2 Title, Entry 4 Title

(Where entry 1 and 3 are category 1 - and entry 2 and 4 are category 2)

This was the closest I got:

    {% set categories = craft.categories.group('jobCategories').find() %}

        {% for category in categories %}

            &lt;h1&gt;{{ category.title }}&lt;/h1&gt;

            {% for entry in craft.entries.section('people').relatedTo(category).find() %}

                &lt;a href="{{ entry.url }}"&gt;
                     {{ entry.title }}
                &lt;/a&gt;

            {% endfor %}

    {% endfor %}


How would I do this?

Thanks!
It might be quicker to turn it around: first get all the entries you need, then group those by their category:

{% set entries = craft.entries.section('people').find() %}

{% for category, catEntries in entries | group('categoryFieldHandle.first().title') %}
    &lt;h1&gt;{{ category }}&lt;/h1&gt;
    {% for entry in catEntries %}
        &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
    {% endfor %}
{% endfor %}