The easiest way is to override the walk() method in your custom walker when using wp_nav_menu

For a reference, see the code inside the walk() method inside the Walker_Nav_Menu class. That code first separates all top level menu items & puts all the submenu items separately. There you can further separate them out to use different start_el functions or outputting some other random html