I have a suggestion, only because I have played around with the idea a bit.
Google for "python factoradics", and you will get my blog entry about
I see the problem statement as "How to obtain batching without
re-sorting multiple times".
If you see a sort order as one permutation of a list, the factoradic
technique provides a key to that permutation. So, in theory, one would
sort the list, and store the factoradic index for that permutation. The
next time the particular sort order is requested, it's a simple matter
of unpacking the factoradic. I have not done any tests to see whether
unpacking a factoradic is significantly less expensive than re-sorting.
Intuitively, it should be. In practice, I am not so sure.
Anyway, this is FWIW. :)
Zope3-dev mailing list