The sort-members should only be applied to class members. The documention says it also sorts the members of namespaces:
Sort the members of a record or namespace
I think part of the confusion was because doxygen also sorts the members of files with the analogous option:
If the SORT_MEMBER_DOCS tag is set to YES then Doxygen will sort the (detailed) documentation of file and class members alphabetically by member name. If set to NO, the members will appear in declaration order.
https://www.doxygen.nl/manual/config.html#cfg_sort_member_docs