Skip to content

Commit 5f72d45

Browse files
Float pinned posts to the top
1 parent c88e857 commit 5f72d45

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

client/main.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2-
// Float pinned posts to the top.
3-
// If they share a pinned/unpinned status, later post comes to the top.
4-
// Otherwise, force pinned post to the top.
2+
// Sort the threads array so that pinned posts float to the top.
3+
// If the threads share a pinned status (both pinned or both not),
4+
// then the thread with the later creation time floats to the top.
5+
// Otherwise, the pinned thread is forced to the top.
56
function pinned_sort($thread_a,$thread_b) {
6-
if ($thread_a["pinned"]==$thread_b["pinned"]) {
7-
return (($thread_a["created"]>$thread_b["created"])? -1 : 1);
7+
if ($thread_a["pinned"] == $thread_b["pinned"]) {
8+
return (($thread_a["created"]<$thread_b["created"]) ? 1 : -1);
89
}
910
if ($thread_a["pinned"]) {
1011
return -1;

0 commit comments

Comments
 (0)