[solved] Collection sorting

Working with many instances in the GUI list, can be difficult when they are sorted by the collectors. I’m sorting the context here by family and name;

import pyblish.api

class CollectSorting(pyblish.api.Collector):

    order = pyblish.api.Collector.order + 0.4

    def process(self, context):

        context[:] = sorted(context,
                            key=lambda instance: (instance.data("family"),

Question is whether we would wanted this by default in Pyblish?

That’s a good question.

Currently, you control the order; either when/how you create instances, or by running something like this at the tail end of collecting.

The problem with having it automatically happen is that you’ll loose this control when you need it.

How do others feel about giving up that level of control? Do you use it?

Another important point is that this also affects the order in which plug-ins are physically processed. That could be useful in some cases, in case one instance somehow depends on another.

And finally (I hope :)) this also mean we’ll lose out on any future ability to move instances around in the GUI to change their order.

Good points:)

People can use this if they want to.

1 Like

Yes, that is a great way of handling it I think. :slight_smile:

After the feature of visualisting collection, this has stopped working. It seems that the GUI keeps its sorting order from when the instances gets added to the context, and ignoring any context reordering post-collection.

This sounds like a bug.

Have a look at adding a test for this in pyblish-qml. There are a few examples there to light the way. If a solution doesn’t pop out to you, I’ll try and take a look at this once the test captures the problem.

Thanks, but a unit-test would be preferable.

Try and reproduce the problem as a test, then we can have a look at passing that test.

Here we go:)

1 Like

Marking this as solved, due to latest PR to pyblish-qml.

1 Like