How to order AActor by distance using TArray::Sort()?

I think that how to sort a TArray of FVectors based on Z attribute? (or X or Y) … and then, based on your answer, I found it:

TargetLocations.Sort([](const FVector& LHS, const FVector& RHS) { return LHS.Z > RHS.Z; });