Fix issues with arranging elements in root

 - Fix the sorting of elements when the CombineRootElements option is
   off.
 - Fix the sorting of elements in root to retain comments.