How do I access the members of a TMap in a predicate for ValueSort()?

Take a look at @trdwll 's comment for an example using copying, but essentially the ValueSort function takes a function as an argument. The members of the TMap to be compared are passed as arguments to the predicate function.

This function takes two values and should return a boolean indicating whether the first parameter is less than the second parameter.

In your case, the code would be

TMap<int32, float> MyMap;

// Some code...

MyMap.ValueSort([](float A, float B)
{
    return A < B;
});

If you aren’t familiar with the [](float A, float B) syntax, this is a lambda/anonymous function. You can read a bit more here: Lambda expressions in C++ | Microsoft Docs

1 Like