sort and filter top n nodes