imenu-sort-function

imenu-sort-function is a variable defined in `imenu.el'.
Its value is
nil

  • This variable may be risky if used as a file-local variable.

Documentation:
The function to use for sorting the index mouse-menu.

Affects only the mouse index menu.

Set this to nil if you don't want any sorting (faster).
The items in the menu are then presented in the order they were found
in the buffer.

Set it to `imenu--sort-by-name' if you want alphabetic sorting.

The function should take two arguments and return t if the first
element should come before the second. The arguments are cons cells;
(NAME . POSITION). Look at `imenu--sort-by-name' for an example.

You can customize this variable.