RealDocs

UKismetArrayLibrary::SortStringArray

function Engine Blueprint Since unknown
#include "Kismet/KismetArrayLibrary.h"
Access: public Specifiers: staticBlueprintCallable

Description

Sorts an array of strings in place, alphabetically by default. Comparison uses standard lexicographic string ordering.

Caveats & Gotchas

  • Sorts the array in place and mutates TargetArray directly; there is no non-mutating overload that returns a sorted copy.
  • The default (unstable) sort does not preserve the relative order of duplicate strings — enable bStableSort if that matters, but expect a performance hit on large arrays.
  • Comparison is case-sensitive and ordinal, so uppercase letters sort before lowercase ones (e.g. "Zebra" sorts before "apple").

Signature

static void SortStringArray(UPARAM(Ref) TArray<FString>& TargetArray, bool bStableSort = false, EArraySortOrder SortOrder = EArraySortOrder::Ascending);

Parameters

Name Type Description Default
TargetArray TArray<FString>& The array of strings to sort in place.
bStableSort bool If true, uses a stable sort that preserves the relative order of equal elements, at a performance cost. false
SortOrder EArraySortOrder Whether to sort ascending or descending. EArraySortOrder::Ascending

Return Type

void

Example

Sort tags alphabetically C++
TArray<FString> Tags = { "Zombie", "apple", "Banana" };
UKismetArrayLibrary::SortStringArray(Tags, false, EArraySortOrder::Ascending);
// Tags is now ["Banana", "Zombie", "apple"] due to case-sensitive ordinal comparison

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.