This is and example of the XML for Pioneer Rekordbox DJ Software.
- Using Python, I am trying to re-sort the XML child tags by the START attribute for each POSITION_MARK tag. The POSITION MARK tag basically represent cue points for the DJ software.
I looked at this Stackoverflow question, but they only sort by whole numbers, not floats:
Python sort XML elements by and tag and attributes recursively
But I need to sort by the float value in each attribute.
- Each TRACK tag has POSITION_MARK child tags with a Start attribute float value.
- How do you re-sort the POSITION_MARK child tags by there float number in the Start attribute.
- This way when it rewrites the XML, each TRACK tags POSITION_MARK children are sorted in ascending order (smallest to largest) by their Start attribute value which is a float value.
How do you sort in Python using xmltree sorted to re-sort the POSITION_MARK children by their START attribute that contain float values?
<?xml version="1.0" ?>
<DJ_PLAYLISTS>
<COLLECTION>
<TRACK>
<POSITION_MARK Start="22.093" />
<POSITION_MARK Start="44.162" />
<POSITION_MARK Start="88.300" />
<POSITION_MARK Start="110.369" />
<POSITION_MARK Start="132.438" />
<POSITION_MARK Start="11.059" />
<POSITION_MARK Start="220.714" />
<POSITION_MARK Start="242.783" />
</TRACK>
<TRACK>
<POSITION_MARM Start="0.024" />
<POSITION_MARK Start="30.024" />
<POSITION_MARK Start="60.024" />
<POSITION_MARK Start="90.024" />
<POSITION_MARK Start="120.024" />
<POSITION_MARK Start="150.024" />
<POSITION_MARK Start="180.024" />
</TRACK>
</COLLECTION>
</DJ_PLAYLISTS>