Closed jakebeal closed 3 years ago
Instead of monkey patching, can you use the key
argument to sorted or sort?
sorted(doc.objects, key=lambda x: x.identity)
I'm reluctant to make objects sortable by their identity
because it seems an arbitrary field to choose, and it is very easy for applications to establish their own sort order using the standard Python sorting routines. I also think this makes the code that wants a sorted order more clear because it will explicitly state what the sort criteria is.
Can we make Identified
objects sortable? Yes. Should we? For me the answer is no.
I hadn't noticed that I would give sorted an argument so compactly; let me try using that
Yes, that will work.
In order to allow SBOL objects to be sortable I have found it useful to monkey-patch the following routine:
Would it be generally a good idea to implement the ordering functions for
Identified
?