if (isset($_GET['sort']) and is_numeric($_GET['sort'])) {
    $sort_topics = $_GET['sort'];
}
//$sort_topics_by = ' position DESC';
/*if ($sort_topics == 1) {$sort_topics_by =  ' published_when DESC, posted_first DESC';}
if ($sort_topics == 2) {$sort_topics_by =   ' topic_score DESC';}
if ($sort_topics == 3) {$sort_topics_by =   ' published_when DESC';}
//Reversed?
if ($sort_topics < 0) {
	$sort_topics_by = ' position ASC';
	if ($sort_topics == -2) {$sort_topics_by =  ' published_when ASC, posted_first ASC';}
	if ($sort_topics == -3) {$sort_topics_by =   ' topic_score ASC';}
	if ($sort_topics == -4) {$sort_topics_by =   ' published_when DESC';}
}
*/
$sort_topics_by = get_sort_topics_by($sort_topics);
echo $sort_topics_by;
//Find Links IN
$topic_idstr = '%,' . $topic_id . ',%';
$tquery = "SELECT topic_id, see_also FROM `" . TABLE_PREFIX . "mod_" . $tablename . "` WHERE see_also LIKE '" . $topic_idstr . "'";
//echo $tquery;
$query_topics = $database->query($tquery);
$linkin_array = array();
if ($query_topics->numRows() > 0) {
    while ($topic = $query_topics->fetchRow()) {
        $linkin_array[] = $topic['topic_id'];
    }
}
$see_also_text = substr($thistopic['see_also'], 1, -1);
if ($see_also_text == '') {
    $see_also_arr = array();
                $see_also_output = '<div class="mod_topic_seealso">' . $see_also_link_title . $see_also_output . '<div class="pnsaclear"></div></div>';
            }
        }
    }
}
//End See_also
//--------------------------------------------------------------------------
//Get Previous and next topics
//--------------------------------------------------------------------------
$see_prevnext_output = '';
$see_next_output = '';
$see_prev_output = '';
$prevnext_array = array();
if ($show_prevnext_links and $showmax_prev_next_links > 0) {
    $sort_topics_by_prev = $sort_topics_by;
    $sort_topics_by_next = get_sort_topics_by(-1 - $sort_topics);
    //Reversed
    /*		
    $sort_topics_by_next = ' position ASC';
    if ($sort_topics == 1) {$sort_topics_by_next =  ' published_when ASC';}
    if ($sort_topics == 2) {$sort_topics_by_next =   ' topic_score ASC';}
    if ($sort_topics == 3) {$sort_topics_by_next =  ' published_when DESC';}
    
    //Reversed?
    if ($sort_topics < 0) {
    	$sort_topics_by = ' position DESC';
    	if ($sort_topics == -2) {$sort_topics_by =  ' published_when DESC, posted_first DESC';}
    	if ($sort_topics == -3) {$sort_topics_by =   ' topic_score DESC';}
    	if ($sort_topics == -4) {$sort_topics_by =   ' published_when ASC';}
    }
    */