Alternative to python list methods for bpy_prop_collection instances? Most interested in sorting I'm writing a script to animate tex characters morphing from one character to another. To make it look smooth, I want to sort the splines in the spline collection within curve data (sorting by key).

This is what I'd like to do, but it doesn't work on the bpy_prop_collection.

spline_collection = obj.data.splines #An instance of bpy_prop_collection
spline_collection.sort(key = lambda x: get_spline_length(x), reverse = True)


If I put the spline objects in a normal python list, this works well, but then I run into issues when I try to put the splines back into a bpy_props_collection instance. (Due to the fact that I can't seem to deepcopy instances of bpy_struct subclasses, which is its own question.)

EDIT:
I did what I needed to do by copying the primitive values I cared about to python lists, then sorting and assigning as needed. A bit of a pain, but it worked.
The blender python API is an API over Blender's internal structure. These structures are designed for performance, hence it cannot be influenced directly.

But the developers have made it quite easy, as you can easily create a local list to do more python stuff. But it is not easy to transfer the results back into blender's database.

spline_collection = list(obj.data.splines)
spline_collection.sort(key = lambda x: get_spline_length(x), reverse = True)


Ps same reason why deepcopy does not work as these objects are not fully python. Most objects have a .copy method you can use.