How to shuffle a TArray?

When I need to shuffle an array I usually do something like this

MyArray.Sort([this](const int Item1, const int Item2) {
	return FMath::FRand() < 0.5f;
});

It’s nice and compact and no extra functions need to be defined.

3 Likes