<xs:complexType name="common">
  <xs:attr name="audio" type="xs:string" use="required" />
  <xs:attr name="firmware" type="xs:string" use="optional" />  
  <xs:attr name="recording" type="xs:unsignedShort" use="required"/>
<xs:complexType/>

I want to sort the xml above by attribute "use" and make sure all of the
elements with "required" would be on top, something like

<xs:complexType name="common">
  <xs:attr name="audio" type="xs:string" use="required" />  
  <xs:attr name="recording" type="xs:unsignedShort" use="required"/>
  <xs:attr name="firmware" type="xs:string" use="optional" />  
<xs:complexType/>

According to pugixml, call std::sort would not give user expected result
because it would not affect the local handle which store in the iterator
The easiest solution for me is make a copy of node "complexType"
sort the iterator of the copy
and assign the value of copy to the original nodes(haven't experienced yet)

Could I sort the nodes with other cheaper and easier solution?
Thanks a lot

you can use qsort with you custom function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.