For markdown-modes I activate
(imenu-add-menubar-index)
(setq-local imenu-auto-rescan t)
This gives me a nice index to navigate by headlines. Sub-headings are nested. And this is my issue.
If I have a markdown file like
# Heading 1
# Heading 2
## Heading 2.1
# Heading 3
In the index entries get sorted as
Heading 2 >
Heading 1
Heading 3
with > indicating, that there are sub-entries.
The Documentation reads:
You can customize the way the menus are sorted by setting the variable imenu-sort-function. By default, names are ordered as they occur in the buffer;
Alas, that doesn't seem true, see the result. For a file of type markdown, sorting entries other than order of appearance in a buffer is counter-intuitive.
Do I have a chance to influence the sort-order?
emacs -Q(no init file), then consider filing a bug report (e.g., saying that the doc is wrong):M-x report-emacs-bug.