you could run the foreach loop twice. first time, you check for nodes that have been modified ($node->modified > some_cut_off_date), assign your results, and run the foreach loop again, (this time $node->modified <= some_cut_off_date unless you want to have new pages appear twice) and use the assign result wherever you want. not sure what that does to performance.