I built a small C++ function sorter on top of flint's Tokenizer.d:
This is a proof of concept implementation (only useful if you
really want your functions to be sorted). The idea is that a
simple scanning of the token array gives you enough structure to
edit your code. This aims to be useful for C++ code generation
and code cleanup. Of course, this is not a general approach but
asks for special purpose tools for each code base. Thanks to D
this could be feasible.