Why is my theme's block preprocess function not reordering elements? I'm trying to do something that seems fairly basic, but I'm having loads of trouble. 

The drupal search_form block outputs an input field and a submit button, in that order.  I'd like to swap the order of those fields.  I'm using theme_preprocess_search_block_form to attempt to reverse the order.  This is my current function:

function mytheme_preprocess_search_block_form(&amp;$data)
{

    $data['form']['search_block_form']['#attributes']['placeholder'] = 'Search ...';
    $data['form'] = array_reverse($data['form']);
    foreach(element_children($data['form']) as $k) {
        if(!empty($data['form'][$k]['#weight'])) {
            $data['form'][$k]['#weight'] *= -1;
        }
    }

    $data['form']['#sorted'] = FALSE;
}


This function does get called, since a var_dump will output to the browser, however, the changes don't make it to the front end. So, what is unchanging my changes?
I figured this out. Drupal can be so infuriating when you are new to it.

The rendering of the search_form_block was happening in a template function file:

bootstrap-search-form-wrapper.func.php. 

containing:

function bootstrap_bootstrap_search_form_wrapper($variables)

The function customizes the rendering of the search form by calling out elements specifically - thus ignoring '#weight'; the wrapper function is part of the bootstrap theme.

The solution is to overwrite the bootstrap theme function with a similar function in our child theme: function mytheme_bootstrap_search_form_wrapper($variables)

o.O

Hopefully this helps someone.