Array sorting callback; sorts elements by title.
function element_sort_by_title($a, $b) {
$a_title = is_array($a) && isset($a['#title']) ? $a['#title'] : '';
$b_title = is_array($b) && isset($b['#title']) ? $b['#title'] : '';
return strnatcasecmp($a_title, $b_title);
}