Craft 3: When querying for Matrix blocks in a plugin, how do you sort by a custom field?
-&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