For the sweet and sour sauce:
Soak the spareribs in a large bowl of cold water for 10 minutes, then drain.
Combine the spareribs, garlic, salt, brown sugar, wine, and soy sauce in a large bowl and marinate for 15 minutes. Stir in the egg, add the flour, and mix well so that each sparerib is coated in flour.
To make the sauce, combine all the ingredients and mix until the sugar is dissolved. Set aside.
Heat the oil in a wok or deep saucepan to 350°F/180°C, or until a cube of bread browns in 30 seconds. Gently lower the spareribs into the oil, in batches, and deep-fry for 3–4 minutes until golden brown and cooked through.
Use a slotted spoon to carefully remove the spareribs from the oil and drain on paper towels.
Pour out most of the oil, leaving only 1 tablespoon in the wok. Heat the oil over medium-high heat, add the onion and stir-fry for about 1–2 minutes until slightly soft. Toss in the bell peppers and the sauce and simmer for 2–3 minutes until the sauce thickens.
Add the spareribs and toss quickly until each piece is fully coated with the sauce. Stir in the pineapple and heat through, then transfer to a serving plate and garnish with cilantro (coriander), if using. Serve with rice.
Adapted from China: The Cookbook by Kei Lum and Diora Fong Chan (Phaidon, 2016)