SimplePie::sort_items PHP Method

sort_items() public static method

Sorting callback for items
public static sort_items ( SimplePie $a, SimplePie $b ) : boolean
$a SimplePie
$b SimplePie
return boolean
    public static function sort_items($a, $b)
    {
        $a_date = $a->get_date('U');
        $b_date = $b->get_date('U');
        if ($a_date && $b_date) {
            return $a_date > $b_date ? -1 : 1;
        }
        // Sort items without dates to the top.
        if ($a_date) {
            return 1;
        }
        if ($b_date) {
            return -1;
        }
        return 0;
    }

Usage Example

/**
 * Take the namespaced function and make it global so that it can be called by usort().
 */
function sort_items($a, $b)
{
    return SimplePie::sort_items($a, $b);
}
All Usage Examples Of SimplePie::sort_items