How to change order of custom module theme output? I need to add some top links and sub top links . I altered hook_theme function and created two templates for these 
code is like this-

function acts_theme() {
    return array(
            'acts_top_links' =&gt; array(
                    'variables' =&gt; array(
                            'links' =&gt; NULL,
                            'activelink' =&gt; NULL,
                        ),
                    'template' =&gt; 'acts-topmenu',
            ),
            'acts_submenu_links' =&gt; array(
                    'variables' =&gt; array(
                            'links' =&gt; NULL,
                            'activelink' =&gt; NULL,
                        ),
                    'template' =&gt; 'acts-submenu',
            ),
    );
}
function template_preprocess_acts_top_links(&amp;$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['toplinks']=$toplinks;
    $variables['activelink']=$activelink;

}
function template_preprocess_acts_submenu_links(&amp;$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['sublinks']=$toplinks;
    $variables['activelink']=$activelink;
}


Now I am using these theme output as-

function acts_display(){
    $build['acts_toplinks'] = array(
            '#theme' =&gt; 'acts_top_links',
            '#links' =&gt; $toplinks,
            '#activelink'=&gt;'Company Law',
    );
    $build['acts_sublinks'] = array(
            '#theme' =&gt; 'acts_submenu_links',
            '#links' =&gt; $submenulinks,
            '#activelink'=&gt;'/companylaw/acts',
    );

    $build['acts_table_rows'] = array(
            '#theme' =&gt; 'table',
            '#rows' =&gt; $rows,
            '#empty' =&gt; t('Currently there are no active content'),
    );
return $build;
}


I expect output as -
first to show- top links, then sub menu links and then table but output exactly reverse- 
first I get table,then sub menu links and then top links
How can I achieve this?
If you add the #weight property to the arrays in $build() then that will allow you to order them e.g.: 

$build['acts_table_rows'] = array(
        '#theme' =&gt; 'table',
        '#rows' =&gt; $rows,
        '#empty' =&gt; t('Currently there are no active content'),
        '#weight' =&gt; 99,
);