10

I am aware of a similar question for C#. I downloaded and tried NArrange and UniversalIndentGUI but both do not sort functions of C++ code per name. Does anyone know a non-commercial tool that does this job?

3
  • 3
    Out of interest: Why do you want to do this? Usually, you want to have related functions together, not functions whose names happen to be similar. Nov 9, 2011 at 10:44
  • 2
    I have to deal with code which I want to structure better. Related functions are all in the same file and those shall be sorted alphabetically.
    – Michael S.
    Nov 9, 2011 at 11:17
  • @OliverCharlesworth Another reason to do this: I have some python code that generates C++ headers based on some protocol reference information... I want to diff an old generated C++ header with one generated now off the new protocol reference, but there's probably an extra message or two - and/or a difference in the way the python interpreter I'm using this time hashes or chooses bucket counts, such that iteration to print the functions now produces a different pseudo-random ordering. If I could sort new and old generated headers, I could get a nice clean diff. Dec 27, 2022 at 2:02

1 Answer 1

-5

Unless you're under orders to rearrange the code to conform to an arbitrary coding standard, my advice is do not do this. I've seen people do it before, and the results are not pretty. The file will look completely different after you're done, and you'll have effectively trashed all of the edit history in source control. Any diffs between this version and any version that came before it will look like a jumbled mess. In the long run, having a clear diff history is worth more to you and your team than some measure of code cleanliness.

2
  • 4
    Agreed doesn't answer the question
    – Paul Grove
    Jan 15, 2016 at 12:23
  • And so I am "under orders to rearrange the code to conform to an arbitrary coding standard" how do I do this? (This is the actual case, not just hypothetical)
    – Vality
    Mar 8, 2017 at 22:07

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.