How to sort grouped tasks by with a field "priority" that is defined in page?

What I’m trying to do

I’d like to adapt this dataview task query to sort group of tasks by a field value. Field can be called e.g., “priority”, and it’s defined in a page, like this: “priority::10”

This is what I have now, groups are sorted by origin.file.mtime currently, but it’s not sufficient.

TASK FROM "" WHERE contains(text, "#task") AND !completed GROUP BY as origin SORT origin.file.mtime DESC

Things I have tried

I’ve searched many times, but failed to find this scenario. And I cannot figure out the way how to access in this query from sort origin.file the field value.
Thank you for your help!

We need to see some examples of your task, both to be able to reproduce your issue, and to help you understand what is going on.

But if you’re grouping by then that could hinder sorting outside of that group. And when you’re sorting on the modification time, it doesn’t sort on anything else…

Finally, if the priority is given for the entire file, that might also affect stuff.

So please provide some more information, to enable some of us to possibly help you any further.

Bonus tip: How to present code properly in a forum post

If you want to showcase either markdown, or code blocks, or dataview queries properly in a forum post, be sure to add one line before and one life after what you want to present with four backticks, ````. This will ensure that any other backticks (like for code blocks) is properly shown.