Skip to content

Commit

Permalink
Float pinned posts to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
MineRobber9000 committed Oct 8, 2019
1 parent c88e857 commit 5f72d45
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/main.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
// Float pinned posts to the top.
// If they share a pinned/unpinned status, later post comes to the top.
// Otherwise, force pinned post to the top.
// Sort the threads array so that pinned posts float to the top.
// If the threads share a pinned status (both pinned or both not),
// then the thread with the later creation time floats to the top.
// Otherwise, the pinned thread is forced to the top.
function pinned_sort($thread_a,$thread_b) {
if ($thread_a["pinned"]==$thread_b["pinned"]) {
return (($thread_a["created"]>$thread_b["created"])? -1 : 1);
if ($thread_a["pinned"] == $thread_b["pinned"]) {
return (($thread_a["created"]<$thread_b["created"]) ? 1 : -1);
}
if ($thread_a["pinned"]) {
return -1;
Expand Down

0 comments on commit 5f72d45

Please sign in to comment.