HeapSort with TArray of pointers fails to compile

Hi, this example code fails to compile:

struct FMyObject
{
	int32 Number;
};

///////////////////////////////////////////////////////////////////////////////

struct FMyObjectComparator
{
	FORCEINLINE bool operator()(const FMyObject& A, const FMyObject& B) const { return A.Number < B.Number; }
};

///////////////////////////////////////////////////////////////////////////////

void SomeCode()
{
	TArray<FMyObject>	SolidObjects;

	SolidObjects.Heapify(FMyObjectComparator());	// compiles fine
	SolidObjects.HeapSort(FMyObjectComparator());	// compiles fine

	TArray<FMyObject*>	ObjectPtrs;

	ObjectPtrs.Heapify(FMyObjectComparator());		// compiles fine
	ObjectPtrs.HeapSort(FMyObjectComparator());		// ERROR CITY
}

Is this a known issue? Is there a workaround?

Many thanks,
-.

[Edited]

According to the comment it’s looking for a < operator within your object - but it seems to be stuck looking for the dereferencing comparison that the normal sort uses in one code branch and the pointer version in another.

I don’t really like the dereferencing behavior tbh as I don’t really like the possibility of references to null objects.

Searching for HeapSort it has a single use in my version of the engine - unless there is a specific reason you want a heap sort you could probably just Sort with a PREDICATE_CLASS.

static bool SortOnLowerCase(const FString& pA, const FString& pB)
{
	return pA.ToLower() < pB.ToLower();
}

....

headerList.Sort(SortOnLowerCase);

Or sort with a lambda:

sortTable.Sort([](const SortItem &rA, const SortItem &rB)->bool { return rA.m_fWidth > rB.m_fWidth; });

There was a specific (performance) reason I wanted to use HeapSort.

I can believe that - though I haven’t looked into the Sort implementation apparently someone figured that the heapsort was needed.

Perhaps sort a wrapper object that contains a pointer?

And submit a feature request / bug report.