"The way" means the prescribed punishment. Sufyan said, "so harm them both" refers to unmarried persons, and "confine them to their houses"
refers to those who have been previously married.
حدثنا أحمد بن محمد بن ثابت حدثنا موسى يعني ابن مسعود عن شبل عن ابن أبي نجيح
السبيل الحد قال سفيان {فآذوهما} البكران {فأمسكوهن في البيوت} الثيبات