Craft 3: When querying for Matrix blocks in a plugin, how do you sort by a custom field? My goal is to order an element query of Matrix blocks by a custom field. Any thoughts?

namespace modules\mymodule\services;

use Craft;
use yii\base\Component;
use craft\elements\MatrixBlock;

class MyService extends Component
{
    public function myFunction()
    {
        $blocks = MatrixBlock::find()
            -&gt;type('myBlockType')
            -&gt;orderBy(???)
            -&gt;all();
    }
}


Edit to show working Example

(This is showing how I used this to sort by a custom date field)



$blocks = MatrixBlock::find()
    -&gt;type('blockType')
    -&gt;fieldId($fieldId)
    -&gt;where(['&gt;', 'content.field_blockType_fieldHandle', new \yii\db\Expression('NOW()')])
    -&gt;orderBy(['content.field_blockType_fieldHandle' =&gt; SORT_ASC])
    -&gt;all();
-&gt;orderBy('fieldHandle')


or

-&gt;orderBy(['fieldHandle' =&gt; SORT_DESC])


But you have to make sure the field is sortable, otherwise it won't work