Book Navigation Block does not sort Books by weight
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #2828681. -->
Reported by: [mtnguru](https://www.drupal.org/user/1672174)
Related to !32
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The Book Navigation Block does not sort the list of books by weight.</p>
<p>A weight can be assigned to the first page of a book through the outline tab, however it has no effect.</p>
<p>I've created a patch and will submit it shortly. It's my first patch!</p>
<p>NB: this concerns the order of <strong>multiple</strong> books, <strong>NOT</strong> ordering pages <em>within</em> a book.</p>
<p><strong>Steps to Reproduce:</strong></p>
<ul>
<li>Enable the book module (it's in core)</li>
<li>Create two books:</li>
<li>Add content > Book page >
<ul>
<li> Title: 'My first book'</li>
<li> Expand 'Book outline' settings - choose 'Create a new book'</li>
<li> Then do the same for 'My second book'</li>
</ul>
</li>
<li>Structure > Block layout > Add a Book navigation block in the sidebar<br>
(Use the default settings.)</li>
<li>Observe that it shows 'My first book' then 'My second book'</li>
<li>Click the second book, Outline tab, change the weight to negative (so it should appear above book 1 in the list)</li>
<li>Observe list is still in the same (wrong) order.</li>
<li>Apply patch, refresh, order should have changed.</li>
</ul>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Simple sort of books using sortByWeightElement.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>- Write tests.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None.</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None.</p>
issue