Sorting Comment Threads

Front End
Version 2.0.0-beta1+
2 min read

Meerkat 2 has tossed away the sorting system from previous versions of Meerkat and replaced it with a new, more powerful system. The syntax for sorting comments is different from previous versions, but the capabilities it unlocks are worth it.

By default Meerkat will sort comments by their id in descending order (internally, Meerkat comment identifiers are the UNIX timestamp of when they were submitted).

Ordering Comments

To specify a custom sort order, we can use the orderby parameter in the {{ meerkat:responses }} tag:

{{ meerkat:responses orderby="id,desc" }}

{{ comments }}
  <!-- Render the comment thread here. -->
{{ /comments }}

{{ /meerkat:responses }}

The syntax for specifying sort order is:


The following directions are available:

Variable Description
asc Sorts the property in ascending order (smallest to biggest).
desc Sorts the property in descending order (biggest to smallest).

The property name and direction are always required.

Ordering by Multiple Properties

Multiple sort orders can be applied to a single comment thread by chaining sort orders with the pipe (|) character. The following example demonstrates how to first sort by newest comments, and then by the contents of the comment:

{{ meerkat:responses orderby="id,desc|content,asc" }}

{{ comments }}
  <!-- Render the comment thread here. -->
{{ /comments }}

{{ /meerkat:responses }}

Available Orderable Parameters

There are many variables that can be used when sorting comment threads; please consult the Default Variables article for information about which properties are available. Compound properties may not be currently supported (i.e.,