Magento apply sort order for the search criteria interface repository by using Magento\Framework\Api\SortOrderBuilder Class.
You can do sorting by ASC or DESC order by any field type for a given search criteria repository.
$sortOrder = $this->sortOrderBuilder ->setField('created_at') //FIELD_NAME ->setDirection(SortOrder::SORT_DESC) // SORT_TYPE ->create();
You can check the given code snippet to fetch orders by created date with the search criteria builder order repository. Continue reading “How to apply SortOrder on Search Criteria Repositories Magento 2?”