Can an 'Advanced Sorting' config be saved so that it's the default when clicking a column header?

Say you’d like to sort the Version page by Episode, sub-sorted by Scene. In the example below the goal is a little more specific, where we’re sorting not by the Scene column (a text / human-friendly field) but a hidden “SceneSort” a numeric field.

Either way it’s an Advanced Sort which we’d like to be the default when clicking the Episode column header.

Is that possible?

I’m not entirely sure I understand but you can definitely save sorting options by saving this through the “edit page” function.

1 Like

Can definitely save sorting options by saving this through the “edit page” function

By “edit page” function, do you mean “design page” function? I didn’t immediately find an option to do that there, but I’ll look into it in more detail.

I’m not entirely sure I understand

The default behavior when you click a column header is to sort by that column, ascending. Click again, and it sorts by that column, descending. Either way it’s a simple sort.

If you right-click the header and select “configure field” you can change the sort field that’s used for the above-described sort, but that’s still a one-field-only sort, with no sub-sorting functionality.

By contrast if you click right-click the header and select “Advanced Sorting…” you can access a 3-level sort (i.e. Sort, Sub-sort, Sub-Sub-Sort). That’s fantastic BUT I’d like to set that up and “assign” it to the header when clicked.

Unfortunately, so far, after setting up an “Advanced Sort”, it goes away when you click a header, and you have to set it all up again.

Ideally I’d like to be setting up a variety of “Advanced Sorts” for a given page, each one accessible by clicking a different column header.

I don’t think this saved Advanced Sort is possible.
Instead you’d likely want to make duplicate views of the current page, each view with the Advanced Sort configured and saved.
It’s a bit fragile, since depending on your Permissions, anyone may be able to save the page with their sorting choices.


The views approach will be fine, though creating a whole view for the purpose of handling a sort feels like overkill. There’s something to be said for accessing sophisticated sorting and grouping within the same view – it would allow the overall project to be a bit tidier and easier to manage. Maybe a feature request. Either way, thank you!

1 Like

In that case, please create a roadmap feature request here:

(the link preview is not very helpfull but it leads you to the roadmap)

1 Like

Roadmap feature request posted. Thanks.

Is there a way in SG to add custom buttons to a view? I looked into Scripts and Widgets, but neither seems capable of handling this. Scripts look like they are only for API access, correct? (already using that – loving the API), and Widgets look very cool (looking forward to making use of those), but are not even remotely appropriate for the above question.

Is there another feature buried somewhere that might make custom Advanced Sorts a one-click option within a given View?

1 Like

Creating Buttons can be done via creating apps for tk-shotgun in Toolkit or by creating an AMI (Action Menu Item) which can do a get/post request to a handler (like a python web server) and run api code etc.

However I don’t think you can set the sorting of a page using the api since it’s kind of web-session related (but I may be wrong).

You can definately set the sort order of various items in the APi (i.e. the sort order of versions in a playlist, on a per playlist level).

1 Like

So it sounds like you can put a button in a View (correct?) that can be used to trigger something on a remote server, correct? (which would be very cool and useful), but that same button would not be able to execute an “Advanced Sort” in a currently-displayed View.

That sounds right. Assuming a button can only make calls to an external server (true?), anything that button could do with the subsequent response/callback it could have done anyway.

1 Like

You can indeed add AMI buttons to Entity views (but not on the sort field).

See this documentation for examples:

@Ricardo_Musch This is very cool. Thanks! Confirming: it looks like it won’t help with the original question, correct? where the goal is to create some kind of a shortcut executes an Advanced Sort. I originally posed it as a column header click, but a button would be fine as well. Other than preparing Views with baked-in sorts there is no way other shortcut to achieving Advanced Sorts?

Well, not currently like that.

However I would suggest something:

  • Create a Custom Sort field with numbers

  • Create AMI Buttons for sorting the shotlist according to your specific requirements
    This AMI button will call out to a python server and the python server will run custom api code and sort the custom field on the shots according to how you want to sort
    The AMI can poll for updates and reload the page

  • If your page is setup to sort accoridng to the custom number field this should now sort the page according to your button code.
    However this happens for everyone, so anytime any of your advanced sort buttons is clicked, the sorting is changed for all users.

Ok – so it sounds like on the server side Python would, when it receives the click, re-define the page View’s default sort – which is why all users would experience the consequence of one users’s click. Did I get that correct?

No I just layed out a custom way to do an advanced sort like how you want, via a button.

It’s very custom as you would simply create a new field with numbers (the sort order if you will) and then have an api script do some magic to create a sort order for each shot and apply it to those records.

If in the web interface you then sort the page according to that custom field it should sort the page to your liking.

It’s not a native thing but rather an elaborate custom thing to achieve somewhat the same result.

1 Like

If you can give an example of the workflow you are after with a bit more background maybe we can suggest a more clever way to achive what you want.

Currently I don’t really understand what your “scenesort” is supposed to do.

The original goal was to have one-click access to a number of Advanced Sorts on a given View.

For example: Click, say “Button A”, and the View sorts by Episode, sub-sorting on Scene.
Then click “Button B” and the same View sorts by Status, sub-sorting by Due Date.
Then click “Button C” and the same View sorts by Status, sub-sorting by Creation Date.

The idea of SceneSort was just a minor elaboration of the above. We can ignore it for now. Our “Scene” column is a human-readable text field that sometimes has things like “34/33” which causes out-of-order sorts. “SceneSort” is a hidden numeric field that might have only 33 in it, such that a sort of Episode sub-sorting by SceneSort puts things in correct numerical order.

Would an Event Daemon or a Webhook that acts on a change in the “Scene” column, updates the SceneSort column with a sanitized number, not work?

Not necessarily, because the changing the contents of the sort field would make a sort change for all active users. The use case, say, someone sitting in front of the list trying to answer multiple questions: “Let me see all the Versions across all episodes. Ok, how many do we still have to go? When are the next ones due?” – so an individual user sorting and filtering in a variety of ways in rapid succession to form a picture that answers an array of questions, all within the same View.

Your response above, BTW, hints at a clever alternative:
Dedicated hidden sort fields that codify two fields in a single sortable one. e.g. click on “Episode” column which is set to sort by a hidden EpisodeScene field containing entries like 1.01, 1.05, 1.19

I believe such a “2 fields codified into one” style field can even be calculated, correct? I think I saw somewhere that SG recently introduced calculated fields.

Calculatd fields have been there for a while but they recently introduced more options for calculations so indeed your use case may be possible that way.

You could indeed make a custom field per sort option and give that a numerical values which sorts stuff according to that option.

I still am not sure if calculated fields are going to give you what you need here but its a start.

1 Like

Success. The calculated field approach – combining 2 into 1 as a means of achieving a 2-field sort – works.

1 Like