Put onions in a hot dry non-stick skillet. Sprinkle with sugar and fry over medium heat, stirring, until onions begin to brown. Add butter and cook until onions are tender, about 7 minutes. Remove from heat. Spread half of the mashed potatoes into a greased, 2-quart shallow baking dish. Arrange slices of meat on top, then onions, peas, and gravy. Cover with remaining mashed potatoes. Bake at 375° for 30 minutes; top with shredded cheese and bake 10 minutes longer, or until casserole is browned and cheese is melted.