Sorting Datatable in C++ for Blueprints?

Hi All,

I am creating a datatable containing several tags as parameters and I want to sort the entire data table based on specific criteria (e.g. value of column “Value” >= 100) and output a cropped array of all rows to my Blueprint.

What would be the most efficient way to do that in C++?

Many thanks for your help

I’m a bit of a beginner so I can’t say if it’s fastest way (I don’t think you can sort datatables). But I would create a new struct with the row name and the value you want to sort by. Then create an TArray of that struct.

USTRUCT() struct FMySortingStruct {
	GENERATED_BODY()
	FName RowName;
	float MyFloatValues;
};

TArray<FMySortingStruct> MySortingArray

Populate the array with the findrow command. Use a sorting algorithm on said MySortingArray. Lastly output the RowNames from the TArray to your Blueprint.
(but maybe my brain is dum-dum)

1 Like

Thanks for the reply. I am currently doing just that but with the entire data table row. Creating a proxy row with an index and the sorting variable is a smart idea, this will surely reduce my memory requirements.

1 Like