Mnemo::_sortByModDate PHP Method

_sortByModDate() protected static method

Comparison function for sorting notes by modification date.
protected static _sortByModDate ( array $a, array $b ) : integer
$a array Note one.
$b array Note two.
return integer 1 if note one is greater, -1 if note two is greater; 0 if they are equal.
    protected static function _sortByModDate($a, $b)
    {
        // Get notes` history
        $history = $GLOBALS['injector']->getInstance('Horde_History');
        $guidA = 'mnemo:' . $a['memolist_id'] . ':' . $a['uid'];
        $guidB = 'mnemo:' . $b['memolist_id'] . ':' . $b['uid'];
        // Gets the timestamp of the most recent modification to the note
        $modDateA = $history->getActionTimestamp($guidA, 'modify');
        $modDateB = $history->getActionTimestamp($guidB, 'modify');
        // If the note hasn't been modified, get the creation timestamp
        if ($modDateA == 0) {
            $modDateA = $history->getActionTimestamp($guidA, 'add');
        }
        if ($modDateB == 0) {
            $modDateB = $history->getActionTimestamp($guidB, 'add');
        }
        if ($modDateA == $modDateB) {
            return 0;
        }
        return $modDateA > $modDateB ? 1 : -1;
    }