Sort directory items by last modified before caching

Change-Id: I41ede1d8f0bdf06ac0d4ab2feea2c83fc6613393