more sort for links and comments, some code optimization