Added sorting for threads and added comment_ctr in Threads table in database