--- a/course/recent.php
+++ b/course/recent.php
@@ -263,9 +263,10 @@
 
 function compare_activities_by_time_desc($a, $b) {
     // make sure the activities actually have a timestamp property
-    if ((!array_key_exists('timestamp', $a)) or (!array_key_exists('timestamp', $b))) {
-      return 0;
-    }
+    if (!array_key_exists('timestamp', $a))
+        return 1;
+    if (!array_key_exists('timestamp', $b))
+        return -1;
     if ($a->timestamp == $b->timestamp)
         return 0;
     return ($a->timestamp > $b->timestamp) ? -1 : 1;
@@ -273,9 +274,10 @@ function compare_activities_by_time_desc($a, $b) {
 
 function compare_activities_by_time_asc($a, $b) {
     // make sure the activities actually have a timestamp property
-    if ((!array_key_exists('timestamp', $a)) or (!array_key_exists('timestamp', $b))) {
-      return 0;
-    }
+    if (!array_key_exists('timestamp', $a))
+        return -1;
+    if (!array_key_exists('timestamp', $b))
+        return 1;
     if ($a->timestamp == $b->timestamp)
         return 0;
     return ($a->timestamp < $b->timestamp) ? -1 : 1;
