Sort by Matrix Field I was using this code in the past and it worked well

        {% set assets = craft.assets.limit(null) %}
        {% set entries = craft.entries.section('menu').limit(3).order('RAND()').relatedTo({
            targetElement: assets,
            field: 'assets'
        }) %}

        {% for item in entries %}
                {% set i = item.assets.first() %}

                &lt;img width="{{ i.getWidth('medium') }}" height="{{ i.getHeight('medium') }}" src="{{ i.getUrl('medium') }}" alt="{{ recipe.title }}" /&gt;

        {% endfor %}


However, in the new version the standalone "assets" field became a part of the matrix field so this piece of code doesn't work anymore. Please advise :)
You can access the assets field by referencing the matrix field first. myMatrixFieldHandle.assets.  So your entries code would be something like this.

{% set entries = craft.entries.section('menu').limit(3).order('RAND()').relatedTo({
       targetElement: assets,
       field: 'myMatrixFieldHandle.assets'
}) %}