Sorting categories into list put single one at end of it I'm trying to put a single category (as long as it's populated) at the end of an category list. My code is working so far, is there an easy way to pick out the 'Others' category and append it to the list?

{% set entryIds = craft.entries.section('toys').ids() %}
{% set categories = craft.categories.relatedTo({ sourceElement:
    entryIds }).craft.categories.group('brands').find() %}

{% for category in categories %}
    {% set image = craft.assets.relatedTo(category).first() %}

    &lt;a href="{{ category.url }}"&gt;
        {% if image|length %}
            &lt;img src="{{ image.url }}" /&gt;
        {% else %}
            &lt;img src="{{siteUrl}}assets/img/placeholder.jpg" /&gt;
        {% endif %}
    &lt;/a&gt;
{% endfor %}


Thanks for any help, ready to learn something new.
Is there a reason why you don’t just drag the “Others” category to the end in the CP? The sort order will be the same for the front-end with your code:

{% set entryIds = craft.entries.section('toys').ids() %}
{% set categories = craft.categories({
    relatedTo: { sourceElement: entryIds },
    group: 'brands',
}) %}


I corrected your code, you never append another .craft.categories criteria model to a criteria model. Have a look at the docs for the allowed syntax: 

https://craftcms.com/docs/templating/elementcriteriamodel

Update:

Here’s example code that should work to list the categories alphabetically with the special “Others” category listed at the end.

{% set entryIds = craft.entries.section('toys').ids() %}

{% set categories = craft.categories({
    relatedTo: { sourceElement: entryIds },
    group: 'brands',
    order: 'title',
}) %}

{% set otherCategory = null %}

{% for category in categories %}
    {% if category.id == 72 %}
        {% set otherCategory = category %}
    {% else %}
        &lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
    {% endif %}
{% endfor %}

{% if otherCategory %}
    &lt;a href="{{ otherCategory.url }}"&gt;{{ otherCategory.title }}&lt;/a&gt;
{% endif %}