Bug 167491 - FEATURE REQUEST : add alphabetization of sections by headers
Summary: FEATURE REQUEST : add alphabetization of sections by headers
Status: NEEDINFO
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 104255 127497 (view as bug list)
Depends on:
Blocks: Navigator
  Show dependency treegraph
 
Reported: 2025-07-13 12:21 UTC by elkareh
Modified: 2025-08-28 14:19 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Test document (14.21 KB, application/vnd.oasis.opendocument.text)
2025-08-28 08:15 UTC, Heiko Tietze
Details

Note You need to log in before you can comment on or make changes to this bug.
Description elkareh 2025-07-13 12:21:54 UTC
Please add the ability in writer to automatically put sections in order according to alphabetization of their headers.  This is very useful when merging two documents that have a large number of headers.
Comment 1 Roman Kuznetsov 2025-07-14 19:36:55 UTC
Do you mean a Navigator in Writer?
Comment 2 elkareh 2025-07-14 21:08:08 UTC
In Writer, you can see all the headers in the Navigator panel in the order of their corresponding sections.  Suppose they are not in alphabetical order and you want them, as well as their corresponding sections, to be.  Or, maybe you merged two documents by copying one at the end of the other, so now all the second document headers and sections are not merged in alphabetical order with the first.  In either case, it would be nice to have a single command that lets the sections be re-ordered alphabetically by the headers, and then also shows the headers in alphabetical order in the Navigator.  I have done this in Microsoft Word.  As far as I can tell, it can't be done automatically in the current version of Writer.  I would find it very useful as I tend to create documents with 50 or more headers.
Comment 3 Heiko Tietze 2025-08-01 09:48:06 UTC
Sounds like a niche use case to me. Assuming we talk about a master document, and you insert multiple documents/files at once, why is the alphabetical order relevant and not, for example, the date/time of modification? And isn't the move up/down feature sufficient?

Or do you just talk about the order of items in the Navigator, similar to headings or bookmarks (bug 160657, bug 86395)?
Comment 4 Heiko Tietze 2025-08-26 06:21:45 UTC
No feedback, resolving as IND.

Please feel free to reopen with further arguments.
Comment 5 elkareh 2025-08-26 07:14:10 UTC
I was referring to the order of the headers both in the document itself and in the Navigator.  In Microsoft Word, it is possible to put those headers, both in the Navigator and the document itself, in alphabetical (or alphanumerical) order.  Is it truly a niche case?  I often create note files that have a large number of headers.  First, it would be nice to be able to just add new sections with headers either at the top or the bottom of the document and not have to alphabetize manually, but rather do it later with a single command.  But even if I alphabetize manually, suppose I later want to merge two lengthy documents with many headers by pasting one into the file of the other.  Then I'd like to have all the headers in alphabetical order again.  In Microsoft Word, I've been able to do this with a single command.  With Writer, it appears to be necessary to do it manually.  This is the only feature from Word that I miss, having switched to LibreOffice Writer.  Or, suppose I had already alphabetized the headers manually, but then I decide to rename some headers, and I'd like to alphabetize again.

To be very concrete, suppose I have one document with headers/sections:
Antibodies
B cells
NK Cells
Post-viral conditions
T cells 

and another document with headers/sections: 
Antibody-dependent enhancement
Dendritic cells
Interferons
Macrophages
NK cells

Now I merge them by pasting one at the end of the other and have headers/sections:
Antibodies
B cells
NK Cells
Post-viral conditions
T cells 
Antibody-dependent enhancement
Dendritic cells
Interferons
Macrophages
NK cells

Maybe with only 10 headers it seems not burdensome to alphabetize manually, but what if each document has 25 headers/sections?  

As to why the alphabetical order is relevant, it just gives me an easier way to navigate around the document that's less cumbersome than using search.  But it also helps me merge sections with identical headers.  In the above example, after the merge I have two headers/sections on "NK cells."  I'd like them to appear next to each other to make it easier to merge them into a single header and section of the same name.
Comment 6 Heiko Tietze 2025-08-28 08:06:15 UTC
(In reply to elkareh from comment #5)
> Is it truly a niche case?
If you sort chapters by any other criteria but creativity I believe a text processor is the wrong tool. But since Word has the feature, although quite awkwardly realized, we should do as well, at least for feature parity.

I suggest to introduce the command .uno:SortChapter that sorts the top-level heading. Or should it also apply to the sub levels?

Example:
<H1>Lorem<H1>
...
<H2>Consectetur<H2>
...
<H2>Ami quis</H2>
...
<H1>Aluctus<H1>
...

=> a) Aluctus, Lorem (Consectetur, Ami quis) or b) Aluctus, Lorem (Ami quis, Consectetur)

We provide an option to sort alphabetically in the Navigator (done for bug 135043 and other). This wouldn't play nicely with the new command, and either we remove it or make it actually sort. What do you think, Jim?
Comment 7 Heiko Tietze 2025-08-28 08:06:58 UTC
*** Bug 127497 has been marked as a duplicate of this bug. ***
Comment 8 Heiko Tietze 2025-08-28 08:09:37 UTC
*** Bug 104255 has been marked as a duplicate of this bug. ***
Comment 9 Heiko Tietze 2025-08-28 08:12:40 UTC
Some support for sorting in the duplicates. Please comment whether a simple sort A-Z is sufficient or if you also need the opposite order (requires a dialog then), or sorting by some other criteria like number of words (hopefully not).
Comment 10 Heiko Tietze 2025-08-28 08:15:36 UTC
Created attachment 202555 [details]
Test document

Some unsorted headings
Comment 11 elkareh 2025-08-28 14:19:21 UTC
From my perspective it would already be very helpful to just be able to sort the Header 1 level.  I certainly would appreciate being able to go to Header 2 level, but it's lower priority, and I understand that you support people are busy and can't do everything.  Ordering alphabetically/alphanumerically is fine and I have never had need for reverse ordering.  I'd like to explain why I like to use Writer for virtually every text-related (or text combined with inserted images) purpose I have, even if developers perceive it as a misapplication: it's the longevity and the ease of sharing with others intrinsic to Writer (and all other LibreOffice) documents.  I freely acknowledge that I use Writer extensively for what might be termed "note-taking" purposes, hence my massive number of headers.  Yes, I could use note-taking software such as Obsidian.  I could work in Markdown .md but I'd lose the wysiwyg benefits and inserting images would be clumsier.  Writer has some great advantages.  I can count on Writer being around years from now; other free software comes and goes.  I save and use my files across years, even decades.  I need to be confident that I can read my older files without major difficulties.  I can share my Writer files with colleagues who use Word.  I can't expect everyone I work with to be using the same niche note-taking software that I happen to be using.  These are the major attractions of using the LibreOffice suite for as many of my documents and purposes as possible.