How to create an array with category ids order by the one that has the most recent post

You could try

$slidercategories_array = array(3,5,6,9,10,11,12,23,24,27);
$in = implode( ',', array_map( 'absint', $slidercategories_array ) );
global $wpdb;
$sql = $wpdb->prepare(
    'SELECT tt.term_id, MAX(p.post_date) AS max_date FROM ' . $wpdb->term_taxonomy . ' AS tt '
    . ' JOIN ' . $wpdb->term_relationships . ' AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id'
    . ' LEFT JOIN ' . $wpdb->posts . ' AS p ON (p.ID = tr.object_id AND p.post_type = %s AND p.post_status = %s)'
    . ' WHERE tt.term_id IN (' . $in . ') AND tt.taxonomy = %s'
    . ' GROUP BY tt.term_id'
    . ' ORDER BY max_date DESC'
    , 'post', 'publish', 'category' );
$slidercategories_sorted = $wpdb->get_col( $sql );