I have a number of XML-files with a structure like this:
<titles>
<title mode="example" name="name_example">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>New York</sort_attribute>
</titleselect>
</title>
<title mode="another_example" name="another_name">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>Boston</sort_attribute>
</titleselect>
</title>
<title mode="final_example" name="final_name">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>Chicago</sort_attribute>
</titleselect>
</title>
</titles>
I am trying to sort the "titles" alphabetically by the "sort_attribute". My desired output is like this:
<titles>
<title mode="another_example" name="another_name">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>Boston</sort_attribute>
</titleselect>
</title>
<title mode="final_example" name="final_name">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>Chicago</sort_attribute>
</titleselect>
</title>
<title mode="example" name="name_example">
<titleselect>
<attribute_a>attrib_a</attribute_a>
<attribute_b>attrib_b</attribute_b>
<attribute_c>attrib_c</attribute_c>
<sort_attribute>New York</sort_attribute>
</titleselect>
</title>
</titles>
Is there anyway to achieve this, preferably using XSLT or Python? I am completely new to the world of XSLT, but I have tried applying a number of solutions from other relevant questions e.g. XSLT sort parent element based on child element attribute to no avail.