sort inputs by dependency order