<?php

$comments = $db->run("SELECT * FROM comment WHERE projectId = 10 AND ssCommentId IS NOT NULL ORDER BY createdAt DESC LIMIT 0,100");

?>

<pre>
    <?php //print_r($comments); ?>
</pre>

<?php

$notifications = $db->run("SELECT * FROM notification WHERE projectId = 10 AND objectType = 'task' AND updateType = 'update' ORDER BY createdAt DESC LIMIT 0,100");

$i = 0;
$tasks = [];
foreach ( $notifications as $notification ) {
    $tasks[$i] = $db->row("SELECT * FROM task WHERE id = ?", $notification['objectId']);
    $tasks[$i]['createdAt'] = $notification['createdAt'];

    $i++;
}
?>

<pre>
    <?php //print_r($tasks); ?>
</pre>

<?php $array = array_merge($comments, $tasks); ?>

<pre>
    <?php //print_r($array); ?>
</pre>

<?php

function cmp($a, $b) {
    $t1 = strtotime($a['createdAt']);
    // echo $a['createdAt']."<br>";
    $t2 = strtotime($b['createdAt']);
    // echo $b['createdAt']."<br>";

    if ( $t1 == $t2 ) {
        return 0;
    }

    return ( $t1 > $t2 ) ? -1 : 1;
}

usort($array, "cmp");

?>

<pre>
    <?php print_r($array); ?>
</pre>