Sorting data table by subcolumn of linked column

First of all, I want to say that the same thing was asked in a feature request https://anvil.works/forum/t/sorting-a-data-table-by-a-subcolumn-of-a-linked-column/6101 and @nickantonaccio was proposing a solution. But asking my question here seemed to be more appropriate.

Due to my general lack of programming skills I could not manage to implement Nick’s solution.

Here is my setup:
I have two tables. One is called “tab_manufacturers” . This table has a column called “manufacturer_name”. The second table is called “tab_products” and consists of the products. The “tab_products” is linked to “tab_manufacturers” with a column called “manufacturer_name”.

The manufacturer table is unlikely to get a lot bigger than 50 rows, and the products table will probably not exceed 10.000 rows (but has images!). So performance issues can be probably ignored.

Can someone guide me to do the “tables.order_by(“manufacturer_name”, ascending=True),” part correctly?

Here is my current code:

sorted_list = app_tables.tab_products.client_readable().search(
            q.fetch_only("product_name"),
            tables.order_by("dia_product", ascending=True),
            # this is the name of the linked column in the tab_products.
            # But I actually want to sort by the sub-column "manufacturer_name"  of that table.
            tables.order_by("manufacturer_name", ascending=True),   
            tables.order_by("claimed_weight", ascending=True),
        )

Thanks!