Fixed MenuBar menu not properly closing.
Use stable sort algorithm for painting.