+ * Reorder links by creation date (newest first).
+ *
+ * @param string $order ASC|DESC
+ */
+ public function reorder($order = 'DESC')
+ {
+ if (! $this->isLegacy) {
+ $this->bookmarks->reorder($order);
+ } else {
+ $order = $order === 'ASC' ? -1 : 1;
+ // backward compatibility: ignore reorder if the the `created` field doesn't exist
+ if (! isset(array_values($this->bookmarks)[0]['created'])) {
+ return;
+ }
+
+ usort($this->bookmarks, function ($a, $b) use ($order) {
+ if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
+ return $a['sticky'] ? -1 : 1;
+ }
+
+ return $a['created'] < $b['created'] ? 1 * $order : -1 * $order;
+ });
+ }
+ }
+
+ /**
+ * Returns the number of bookmarks in the reference data