how to insert an array in another one?
You could try this:

function my_module_home_index(){
  $sections = array();

  $home_livre = db_query("SELECT tax.name as section,field_categorie_tid as tid,field_title_value as titre ,field_prix_value as prix ,t.entity_id FROM {field_data_field_title} as t
    join {field_data_field_prix} as pr on pr.entity_id = t.entity_id
    join {field_data_field_categorie} as cat on cat.entity_id = t.entity_id
    left join {taxonomy_term_data} as tax on tax.tid = cat.field_categorie_tid
    ")-&gt;fetchAll();

  foreach($home_livre as $book){
    if (!isset($sections[$book-&gt;section])) {
      $sections[$book-&gt;section] = array(
        'categorie' =&gt; $book-&gt;section,
      );
    }

    $sections[$book-&gt;section]['livre'][] = array(
      'id_livre' =&gt; $book-&gt;entity_id,
      'titre' =&gt; $book-&gt;titre,
      'prix' =&gt; $book-&gt;prix,
    );
  }

  // The above will set up $sections as an associative array, but you need
  // to return an indexed array, so run it though array_values()
  return array_values($sections);
}


Basically, The first book that comes along with category "A" will create a new child the in $sections array with a key of "A". The book will then be nested in that child. If another book is found with category "A" then instead of creating a new category child, the book is nested inside of the same "A" category.

Note that I've not tested this code live so might need some tweaking