aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/BookmarkArray.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/bookmark/BookmarkArray.php')
-rw-r--r--application/bookmark/BookmarkArray.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/application/bookmark/BookmarkArray.php b/application/bookmark/BookmarkArray.php
index d87d43b4..3bd5eb20 100644
--- a/application/bookmark/BookmarkArray.php
+++ b/application/bookmark/BookmarkArray.php
@@ -234,16 +234,17 @@ class BookmarkArray implements \Iterator, \Countable, \ArrayAccess
234 * 234 *
235 * Also update the urls and ids mapping arrays. 235 * Also update the urls and ids mapping arrays.
236 * 236 *
237 * @param string $order ASC|DESC 237 * @param string $order ASC|DESC
238 * @param bool $ignoreSticky If set to true, sticky bookmarks won't be first
238 */ 239 */
239 public function reorder($order = 'DESC') 240 public function reorder(string $order = 'DESC', bool $ignoreSticky = false): void
240 { 241 {
241 $order = $order === 'ASC' ? -1 : 1; 242 $order = $order === 'ASC' ? -1 : 1;
242 // Reorder array by dates. 243 // Reorder array by dates.
243 usort($this->bookmarks, function ($a, $b) use ($order) { 244 usort($this->bookmarks, function ($a, $b) use ($order, $ignoreSticky) {
244 /** @var $a Bookmark */ 245 /** @var $a Bookmark */
245 /** @var $b Bookmark */ 246 /** @var $b Bookmark */
246 if ($a->isSticky() !== $b->isSticky()) { 247 if (false === $ignoreSticky && $a->isSticky() !== $b->isSticky()) {
247 return $a->isSticky() ? -1 : 1; 248 return $a->isSticky() ? -1 : 1;
248 } 249 }
249 return $a->getCreated() < $b->getCreated() ? 1 * $order : -1 * $order; 250 return $a->getCreated() < $b->getCreated() ? 1 * $order : -1 * $order;