Skip to main content

thread_order

Function thread_order 

Source
pub fn thread_order<T>(
    items: &[T],
    key: impl Fn(&T) -> (CommentId, Option<CommentId>, Option<DateTime<Utc>>),
) -> Vec<ThreadPosition>
Expand description

Depth-first thread order: roots by date, each followed by its replies, by date, recursively. A comment whose parent is not in items is a root. The sorts are stable, so undated items keep the order they came in.

key gives each item’s id, parent and date.