How to sort TArray in c++?

Your example in your question compiles fine for me in MSVC 2019.

For example

TArray<USceneComponent*> TheArray;

TheArray.Sort([](const USceneComponent& ip1, const USceneComponent& ip2) {
	// access some random field just to test compile
	return  ip1.IsDeferringMovementUpdates() < ip2.IsDeferringMovementUpdates();
});

What error did you get? Did you include the file for OfClassPointers so that it’s defined wherever you are trying to sort by it?

9 Likes