protected ForumManager::getTopicOrder($sortby)
Gets topic sorting information based on an integer code.
Parameters
int $sortby: One of the following integers indicating the sort criteria:
- ForumManager::NEWEST_FIRST: Date - newest first.
 - ForumManager::OLDEST_FIRST: Date - oldest first.
 - ForumManager::MOST_POPULAR_FIRST: Posts with the most comments first.
 - ForumManager::LEAST_POPULAR_FIRST: Posts with the least comments first.
 
Return value
array An array with the following values:
- field: A field for an SQL query.
 - sort: 'asc' or 'desc'.
 
File
- core/modules/forum/src/ForumManager.php, line 280
 
Class
- ForumManager
 - Provides forum manager service.
 
Namespace
Drupal\forum
Code
protected function getTopicOrder($sortby) {
  switch ($sortby) {
    case static::NEWEST_FIRST:
      return array('field' => 'f.last_comment_timestamp', 'sort' => 'desc');
    case static::OLDEST_FIRST:
      return array('field' => 'f.last_comment_timestamp', 'sort' => 'asc');
    case static::MOST_POPULAR_FIRST:
      return array('field' => 'f.comment_count', 'sort' => 'desc');
    case static::LEAST_POPULAR_FIRST:
      return array('field' => 'f.comment_count', 'sort' => 'asc');
  }
}
Please login to continue.