1. Cover lentils with water and boil 12-15 minutes, until soft. Drain.
2. Dredge onions in flour and half of salt. Heat the oil in a heavy-bottomed pan and cook the onions until nicely caramelized, adjusting heat to prevent burning.
3. When onions are crisp and browned, remove them from the pan and drain off all but 1-2 tablespoons of any remaining oil. Add the rice, spices, sugar and remaining salt. Stir to mix and add water.
4. Bring to a boil, cover with a lid and simmer over very low heat for 30 minutes. Add lentils and continue to cook for 15 minutes.
5. When the rice is nearly tender, remove from heat and allow to rest 10 minutes, covering with a towel to absorb condensation.
6. Gently stir in half of the onions. Serve and use the remaining onions for garnish.