What can I do to fix my sorting function?

Okay, so I have this function written in c++ that is supposed to sort an array of a struct called FInventorySlots into alphabetical order. Now when I test this inside the game, the function works to some degree but it fails to properly organize the entries of the array into alphabetical order. If anyone could help me solve the issue with my code that would be fantastic. I’m banging my head against a wall trying to figure out what the problem is.
``UGame_Instance* GameInstance = Cast(GetWorld()->GetGameInstance());
TArray LocalFilteredArray = {};

if (IsValid(GameInstance))
{
	FilterEmptyInventorySlots(LocalFilteredArray);

	if (LocalFilteredArray.Num() > 1)
	{
		switch (SortType)
		{
			case EInventorySortingMethodTypes::Item_Name_Sort:
				{
					auto GetSlotItemNameIndex = [](const FInventorySlotData& Slot) {
						auto ItemClass = GetDefault<UInventory_Item>(Slot.ItemClassOnSlot);
							return static_cast<FString>(ItemClass->ItemClassData.ItemBaseData.ItemNameSortingString);
				};
					auto SortPredicate = [&](const FInventorySlotData& SlotA, const FInventorySlotData& SlotB)
				{
						const FString itemNameIndexA = GetSlotItemNameIndex(SlotA);
						const FString itemNameIndexB = GetSlotItemNameIndex(SlotB);

							return bReversedSort ? (0 <= (itemNameIndexA.Compare(itemNameIndexB, ESearchCase::IgnoreCase)))
								: (0 >= (itemNameIndexA.Compare(itemNameIndexB, ESearchCase::IgnoreCase)));
				};
					LocalFilteredArray.Sort(SortPredicate);
					GameInstance->InventoryStorageSlots = LocalFilteredArray;
					GameInstance->InventoryStorageSlots.SetNum(GameInstance->MaxInventoryStorageSlots);
				}``