UKismetArrayLibrary::SortNameArray
#include "Kismet/KismetArrayLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sorts an array of FNames in place. By default sorts lexically (alphabetically by string value) rather than by the raw internal comparison index.
Caveats & Gotchas
- • bLexicalSort defaults to true here, which is slower than sorting by the raw FName comparison index — set it to false only if you need speed and don't care about alphabetical order.
- • Sorting by comparison index (bLexicalSort = false) produces an order based on the name table's internal indices, which depends on registration order and is not alphabetical or stable across runs.
- • FName comparisons are case-insensitive, so names differing only by case are treated as equal for ordering purposes.
Signature
static void SortNameArray(UPARAM(Ref) TArray<FName>& TargetArray, bool bStableSort = false, bool bLexicalSort = true, EArraySortOrder SortOrder = EArraySortOrder::Ascending); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| TargetArray | TArray<FName>& | The array of names 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 |
| bLexicalSort | bool | If true, sorts by the string value of each FName rather than its internal comparison index. Slower, but produces alphabetical results. | true |
| SortOrder | EArraySortOrder | Whether to sort ascending or descending. | EArraySortOrder::Ascending |
Return Type
void Example
Sort socket names alphabetically C++
TArray<FName> SocketNames = { FName("Hand_R"), FName("Foot_L"), FName("Head") };
UKismetArrayLibrary::SortNameArray(SocketNames, false, true, EArraySortOrder::Ascending);
// SocketNames is now [Foot_L, Hand_R, Head] See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?