void FAssetViewSortManager::SortList(TArray<TSharedPtr<FAssetViewItem>>& AssetItems, const FName& MajorityAssetType) const { //double SortListStartTime = FPlatformTime::Seconds(); TArray<TUniquePtr<FCompareFAssetItemBase>> SortMethod; for (int32 PriorityIdx = 0; PriorityIdx < EColumnSortPriority::Max; PriorityIdx++) { const bool bAscending(SortMode[PriorityIdx] == EColumnSortMode::Ascending); const FName& Tag(SortColumnId[PriorityIdx]); if (Tag == NAME_None) { break; } if (Tag == NameColumnId) { SortMethod.Add(MakeUnique<FCompareFAssetItemByName>(bAscending, Tag)); } else if (Tag == ClassColumnId) { SortMethod.Add(MakeUnique<FCompareFAssetItemByClass>(bAscending, Tag)); } else if (Tag == PathColumnId) { SortMethod.Add(MakeUnique<FCompareFAssetItemByPath>(bAscending, Tag)); } else { // Since this SortData.Tag is not one of preset columns, sort by asset registry tag UObject::FAssetRegistryTag::ETagType TagType = UObject::FAssetRegistryTag::TT_Alphabetical; if (MajorityAssetType != NAME_None) { UClass* Class = FindObject<UClass>(ANY_PACKAGE, *MajorityAssetType.ToString()); if (Class) { UObject* CDO = Class->GetDefaultObject(); if (CDO) { TArray<UObject::FAssetRegistryTag> TagList; CDO->GetAssetRegistryTags(TagList); for (auto TagIt = TagList.CreateConstIterator(); TagIt; ++TagIt) { if (TagIt->Name == Tag) { TagType = TagIt->Type; break; } } } } } if (TagType == UObject::FAssetRegistryTag::TT_Numerical) { // The property is a Num2er, compare using atof SortMethod.Add(MakeUnique<FCompareFAssetItemByTagNumerical>(bAscending, Tag)); } else if (TagType == UObject::FAssetRegistryTag::TT_Dimensional) { // The property is a series of Num2ers representing dimensions, compare by using atof for each Num2er, delimited by an "x" SortMethod.Add(MakeUnique<FCompareFAssetItemByTagDimensional>(bAscending, Tag)); } else { // Unknown or alphabetical, sort alphabetically either way SortMethod.Add(MakeUnique<FCompareFAssetItemByTag>(bAscending, Tag)); } } } // Sort the list... if (SortMethod.Num() > 0) { TUniquePtr<FCompareFAssetItemBase> PrimarySortMethod = MoveTemp(SortMethod[EColumnSortPriority::Primary]); check(PrimarySortMethod); SortMethod.RemoveAt(0); // Move all the comparisons to the primary sort method PrimarySortMethod->SetNextComparisons(SortMethod); AssetItems.Sort(*(PrimarySortMethod.Get())); // Move the comparisons back for ease of cleanup SortMethod = MoveTemp(PrimarySortMethod->GetNextComparisons()); SortMethod.Insert(MoveTemp(PrimarySortMethod), 0); } // Cleanup the methods we no longer need. for (int32 PriorityIdx = 0; PriorityIdx < SortMethod.Num(); PriorityIdx++) { SortMethod[PriorityIdx].Reset(); } SortMethod.Empty(); //UE_LOG(LogContentBrowser, Warning/*VeryVerbose*/, TEXT("FAssetViewSortManager Sort Time: %0.4f seconds."), FPlatformTime::Seconds() - SortListStartTime); }