In the MMX IDE toolkit (www.mmx-delphi.de) which I’m quite fond of, there are several tools for sorting your source code. As I guess most Delphi developers are aware, the order that Delphi sorts methods of a class is alphabetical until it’s not alphabetical anymore. Then it’s random.
From the moment I found the sorting tools in MMX I was hooked. There is one tool for dragging and dropping all the methods of the interface and the implementation sections and sort them at a click of a button and another (which is the one I use most) to sort all the methods in the implementation in the same order as you’ve defined them in the interface.
Now, after creating a method (via Ctrl+Shit+C or manually) I always sort the methods in the implementation according to the interface. All I have to do is add the method definitions in the correct order in the interface and then sort the implementation.
This function of the MMX has never failed me. Not once has it screwed up my code, so I’d say it’s very reliable. But I do lack a keyboard shortcut, it won’t sort commentary outside methods (not a big issue for me, I never comment my code) and it won’t handle conditional defines.
Download MMX and give it a go. Apart from sorting methods, there’s lots and lots of other goodies in that pack. And tt’s free.