How can I deterministically sort raw C++ code

I have a few hundred thousands translation units of raw but UE decorated C++ like code:


 "Somefile.h"

class Whatever;

UCLASS(Blueprintable)
class GAME_API USubsystem : public UEngineSubsystem {
GENERATED_BODY()
public:
// etc
private:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
UObject* Data;
}

and the likes for very specific review/overview purpose only, I need to process the code and sort it in a deterministic ABC Order :slight_smile:

all includes are in top, sorted
all forward type declarations follow includes, sorted as well
classes, as whole scoped objects, sorted alphabetically as well, by class name.
within classes, property/field declarations sorted by name
functions follow them
preservation of access modifiers is not required
only header files needs to be processed
How can I possibly achieve it, en masse?