optimize code for sorting news