I ended up implementing my idea.
I’ve described the creation of the custom input field on the Site Info Screen unter Network in this Post. Here is the complete code again:
<?php
// Create custom Input Field on the WP-Admin > Network > Site Info Screen
// for the possibility to order sites manually
add_action('admin_footer', 'pg_custom_site_options');
function pg_custom_site_options(){
global $pagenow;
if( 'site-info.php' == $pagenow ) {
global $details;
$blog_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
if ( ! $blog_id ) wp_die( __('Invalid site ID.') );
$saved_value = get_blog_option( $blog_id, 'blog_order');
?>
<table style="display: none;">
<tr id="user16975_custom_options">
<th scope="row">Order</th>
<td><input type="text" size="5" name="blog[blog_order]" value="<?php echo esc_attr( $saved_value ) ?>" ></td>
</tr>
</table>
<script>
jQuery(function($){
$('.form-table tbody').append($('#user16975_custom_options'));
});
</script>
<?php
}
}
add_action('admin_init', 'pg_save_custom_site_options');
function pg_save_custom_site_options(){
global $pagenow;
if( 'site-info.php' == $pagenow &&
isset($_REQUEST['action']) &&
'update-site' == $_REQUEST['action']
) {
// Use a default value here if the field was not submitted.
$new_field_value="0";
if ( isset( $_POST['blog']['blog_order'] ) ) {
$new_field_value = intval( $_POST['blog']['blog_order'] );
// save option into the database
if( is_int($new_field_value) ){
update_blog_option( $_POST['id'], 'blog_order', $new_field_value );
}
}
}
}
?>
After every site got its order number i’ve placed it in the wp_get_sites-array
$all_standorte = wp_get_sites( $args );
// Get the order nr of each site and save it in the array
$pos = 0;
foreach( $all_standorte as $standort){
$standort_id = $standort['blog_id'];
$blog_order = get_blog_option( $standort_id, 'blog_order', '0');
$all_standorte[$pos]['blog_order'] = $blog_order;
$pos++;
}
The final step is sorting the array with usort().
// Sort Sites by Custom Order
function sort_sites_by_order($a, $b){
// ascending (aufsteigend)
return $a['blog_order'] - $b['blog_order'];
// descending (absteigend, der juengste Artikel zuerst)
// return $b['blog_order'] - $a['blog_order'];
}
usort($all_standorte, 'sort_sites_by_order');