Is there a way to sort view asc or desc using
drupal_view('vn', 'vmn', sort order)
or Can sort we views_embed_view() in controller
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
One alternative approach is to use the exposed sort options provided by Views. Adding exposed sort options is similar to adding exposed filters:
This will expose a select widget to the end user allowing them to choose which of the sort criteria should be used to sort the View. For example, if you choose to expose a Title sort and a Date sort, the end user would see a select field allowing them to choose which sort by Title or sort by Date.
Additionally, you can also expose the sort order for your exposed sort items. For example, choose whether it's Title ASC or Title DESC. To do this, open the Exposed Form > Settings options, in the Advanced tab, and check the box for "Allow people to choose the sort order".
I'd recommend using these options to interface with the backend view and query. If the UX isn't to your liking, perhaps you could render your own select field on the frontend and then set these default views fields per the value selected in your select field.