Changing query to maintain the order in IN clause while fetching trending entries