Sort Tarray of FStrings Alphanumericaly

If you want to sort it by yourself you could just go through the array with a loop and check which string is smaller with the normal comparison operator. Every kind of sorting algorithm should work.

Don’t have time testing this at the moment.

I have a TArray of FStrings that I would like to sort Alphanumerically.
And I know TArray has a sort function which relies on predicates which Im not really familiar with.
How would I go about sorting this array?

TArray.Sort() has two overloads. The first one doesn’t take and arguments, so you can just call MyStringArray.Sort() and it will sort alphanumerically, no predicate logic required.

Thanks, I never noticed that.

Just to add to this, if you wanted to define any custom sorting logic, you could do so by passing a lambda to the sort:

// Sort the array in alphanumeric descending order.
// The predicate should return true if One should be sorted before Two, false otherwise
MyArray.Sort([](const FString& One, const FString& Two){
    return One > Two;
});

This is incorrect for UE5. I’m testing this right now… If you have TArray of FString then the Sort() function is alphabetical, not alphanumerical (aka natural sort).