sort locked deps first before write so it's constant between iterations