Items

Manually Sorting

If you would like to sort your items by the title property (case sensitive), you can simply call:

$workflow->items()->sort();

To sort them by title descending:

use Alfred\Workflows\Items;

$workflow->items()->sort('title', Items::SORT_DESC);

To sort by a custom property, for example subtitle:

$workflow->items()->sort('subtitle');

You can also pass in a function or method as the first parameter and handle the sorting yourself:

use Alfred\Workflows\Item;

$workflow->items()->sort(function(Item $a, Item $b) {
    return $a->arg > $b->arg ? 1 : -1;
});
Previous
Variables