Get view result with sorting option programmattically I've a view with sorting, that I need to call programmatically like,

$view_name = 'view_name';
$display_id = 'page';
$exposed_input = Array
(
    ['field_year_value'] =&gt; 
    ['shs_term_node_tid_depth'] =&gt; All
    ['field_federal_entity_value'] =&gt; All
    ['order'] =&gt; title
    ['sort'] =&gt; desc
);

$exposed_filters = Array
(
    ['field_year_value'] =&gt; 
    ['shs_term_node_tid_depth'] =&gt; All
    ['field_federal_entity_value'] =&gt; All
)

$view = views_get_view($view_name);
$view-&gt;exposed_input = $exposed_input;
$view-&gt;exposed_raw_input = $exposed_filters;
$view-&gt;set_display($display_id);
$view-&gt;pre_execute();
$view-&gt;execute();


But the result is not sorted.

Is there a way to accomplish this?
You could check this sample code. It contains additional methods in Views that you could use like in the line:

//Here we can alter the order
//$view-&gt;set_item('default', 'sort', 'random', NULL);
if(isset($alter['node_created_order'])){
  $view-&gt;add_item('default', 'sort', 'node', 'created',array('order' =&gt; $alter['node_created_order']));
}