Complex sentence: Tipu commanded his soldiers to level up the ditch, so that his army can advance, while retreating Travancorean soldiers and militiamen regrouped on the other side of the ditch.
Split into simpler sentences: Tipu commanded his soldiers to level up the ditch, so that his army can move forward. The retreating soldiers and militiamen from Travancore regrouped on the other side of the ditch.