# Sorting algorithms in Blueprints

**URL:** <https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992>\
**Category:** Programming & Scripting\
**Tags:** sorting, unreal-engine, Blueprint\
**Created:** [April 21, 2023, 5:34pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992 "2023-04-21T17:34:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 21, 2023, 5:34pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/1 "2023-04-21T17:34:17Z")

</div>

It is common knowledge that blueprints do not include sorting functions. In my previous experiences, I have been able to create simple sorting functions easily. However, during my current project, I faced the challenge of sorting large data arrays and found that the sorting process was either very slow or unsuccessful. Since I wanted to avoid using C++ code or third-party development, I independently researched this issue.

After conducting some research, I have decided to share my findings in the hopes that it will be useful to others. I started by studying the theory behind sorting algorithms and discovered that most functions I had previously written or seen on forums were variations of two simple algorithms: Selection and Insertion. However, these algorithms were ineffective for large arrays in blueprints, as they would fail or take a very long time to execute, even when I increased the loop limit to 100,000,000.

To address this issue, I studied several basic algorithms and chose a few to implement with blueprints for testing purposes. Below, I have listed the implemented algorithms in order of increasing performance and included statistics and average time values to compare their effectiveness.

**BUBBLE SORT**

> **[Bubble sort](https://en.wikipedia.org/wiki/Bubble_sort)**
>
> Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping their values if needed. These passes through the list are repeated until no swaps had to be performed during a pass, meaning that the list has become fully sorted. The algorithm, which is a comparison sort, is named for the way the larger elements "bubble" up to the top of the list. 
> This s...

 ![Bubblesort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/0/78022998ab7bddc665471b9ecc0158f139e8c994.jpeg)

 ![BubbleMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/d/b1d3cadc641ffe3e394f85b4b2273f63aa0495ac.jpeg)

**SELECTION SORT**

> **[Selection sort](https://en.wikipedia.org/wiki/Selection_sort)**
>
> In computer science, selection sort is an in-place comparison sorting algorithm. It has an O(n2) time complexity, which makes it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity and has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.
> The algorithm divides the input list into two parts: a sorted sublist of items which is built up from l...

 ![Selsort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/8/8c893eecc7bc7dc02e31c181e446851c1557d820.jpeg)

 ![SelectionMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/2/5a2b4089ed9184ad21cedb6c2247a631e1a3ea05.jpeg)

**INSERTION SORT**

> **[Insertion sort](https://en.wikipedia.org/wiki/Insertion_sort)**
>
> Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time by comparisons. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. However, insertion sort provides several advantages:
> When people manually sort cards in a bridge hand, most use a method that is similar to insertion sort.
> Insertion sort iterates, consuming one input element each repetition, and grows a sorted output list. A...

 ![Insertsort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/f/64f5c22e585c3080264d063389421ab7fe4de9f9.jpeg)

 ![InsertionMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/9/5e959d3ed157c5af50a08bec7265a1ad61b1180a.jpeg)

The first three algorithms are slow and unsuitable for working with large and medium arrays.

**COMB SORT**

> **[Comb sort](https://en.wikipedia.org/wiki/Comb_sort)**
>
> Comb sort is a relatively simple sorting algorithm originally designed by Włodzimierz Dobosiewicz and Artur Borowy in 1980, later rediscovered (and given the name "Combsort") by Stephen Lacey and Richard Box in 1991. Comb sort improves on bubble sort in the same way that Shellsort improves on insertion sort.\[clarification needed\]
> nist.gov's "diminishing increment sort" definition mentions the term 'comb sort' as visualizing iterative passes of the data, "where the teeth of a comb touch;" the for...

 ![Combsort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/d/43dac6a8da04ddd7b861bb526c584edda778e8a3.jpeg)

 ![CombMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/3/fd3690f92d19c6324f2408bf75caddc767763238.jpeg)

**SHELL SORT**

> **[Shellsort](https://en.wikipedia.org/wiki/Shellsort)**
>
> Shellsort, also known as Shell sort or Shell's method, is an in-place comparison sort. It can be seen as either a generalization of sorting by exchange (bubble sort) or sorting by insertion (insertion sort). The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. By starting with far apart elements, it can move some out-of-place elements into position faster than a simple nearest neighbor exchange. Donald Sh Sh...

 ![Shellsort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/f/25f4a1fb7b24534fd1fd1dc4475380912eb2fce0.jpeg)

 ![ShellMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/d/fed8e5032aa44b08ff92fc5b5e0cb489ac56b8bb.jpeg)

Comb sort and Shell sort work much better and show good results even on large arrays.

I noticed one interesting thing - all of the above algorithms work twice as slowly in macros.

The following two algorithms are more complex and contain recursion.

**QUICK SORT**

> **[Quicksort](https://en.wikipedia.org/wiki/Quicksort)**
>
> Quicksort is an efficient, general-purpose sorting algorithm. Quicksort was developed by British computer scientist Tony Hoare in 1959 and published in 1961. It is still a commonly used algorithm for sorting. Overall, it is slightly faster than merge sort and heapsort for randomized data, particularly on larger distributions.
> Quicksort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to ...

 ![Quicksort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/7/147b6ebd8ee43f945118cfc021323988ce1a3c09.jpeg)

 ![QuicksortImpl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/e/04eb306f666eb8d285e878fd0420a71e8e1c7468.jpeg)

 ![Partition](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/a/87aa5a6b1bf1e8497fa9069fd5d61608fc4bc87d.jpeg)

**INTROSORT**

> **[Introsort](https://en.wikipedia.org/wiki/Introsort)**
>
> Introsort or introspective sort is a hybrid sorting algorithm that provides both fast average performance and (asymptotically) optimal worst-case performance. It begins with quicksort, it switches to heapsort when the recursion depth exceeds a level based on (the logarithm of) the number of elements being sorted and it switches to insertion sort when the number of elements is below some threshold. This combines the good parts of the three algorithms, with practical performance comparable to quick...

I didn’t use heapsort as it’s overkill for blueprints and replaced insertion sort with comb sort as the results were better.

 ![Introsort](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/d/73de4558339ff734d6c5e9b5b9e12f421def51ca.jpeg)

 ![IntrosortImpl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/e/74e9b0da09b4144e3eb32aa30ac7dd764e03bf97.jpeg)

I used a shuffle at the input to the Quicksort and intro sort functions to avoid efficiency degradation on partially sorted arrays.

Quicksort and Introsort are the fastest, but they are unusable in macros due to recursion.

**STATISTICS**

Please look at the comparative results of testing algorithms I collected while working on this study.

![StatFloatsFunc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/a/4/2a444122d9d9235269e3a84a058bc8a1fb424fbc.png)

![StatFloatsMacro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/6/d26e9040f87d40abb9af551872fd3fcf8bd8fe78.png)

**CONCLUSIONS**

In my **Quiet Runtime Editor** , I needed to sort large arrays of indexed names, and I found that the sorting process was taking a long time. However, after implementing the algorithms I’ve shared above, I achieved a **30-40** times speed improvement. While any of these algorithms will work for sorting small arrays, I recommend using **Shellsort** for medium and large arrays due to its simplicity and efficiency.

The project that prompted me to do this research:

> **[Quiet Runtime Editor in Blueprints - UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/quiet-runtime-editor)**
>
> Quiet Runtime Editor is designed to build and edit 3D scenes runtime. Version 2.1

Also, I’ve created a study project that includes all of the algorithms and auxiliary functions mentioned. The project also includes functions for sorting arrays of strings alphabetically, both with and without Numerical string sorting. Feel free to download and use it!

 ![StatTools](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/3/753654a11c3521a4009a25937fc64243629aae04.jpeg)

[SortingAlgorithms\_5.0.zip](https://forums.unrealengine.com/uploads/short-url/6XBr8cEMpXlMYUWGZCVRJ1FQrfD.zip) (326.6 KB)

It would be great if you added other algorithms and published your statistics to expand this research.

---

<div class="post-metadata">

**Author:** ![Gil](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gil/32/909199_2.png) [@Gil](https://forums.unrealengine.com/u/Gil)\
**Post date:** [April 22, 2023, 3:00pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/2 "2023-04-22T15:00:12Z")

</div>

Just came across this on Reddit. This is so ■■■■■■■ great! Why not doing a plugin of this with function written in c++ but exposed in BP (if that’s not yet the case)?

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 22, 2023, 7:47pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/3 "2023-04-22T19:47:32Z")

</div>

I should have clarified that C++ code is several orders of magnitude faster, and on very large arrays, this is the only option.

There is a free plugin library:

> **[LE Extended Standard Library in Code Plugins - UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/low-entry-extended-standard-library)**
>
> This plugin provides you with blueprints that add general functionality and improvements.

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 24, 2023, 6:57am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/4 "2023-04-24T06:57:04Z")

</div>

**Compare strings:**

**SIMPLE**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/a/aba8d4d9fb1e0a251adef4ad953d2325a4ac77f7.png)

WITH NUMERIC

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/3/43339c81b2c3429c0728f40c1f13950b529eccb1.png)

 ![EndsWithNumber](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/7/d774f4dd711d0ffe296fc7e470ffbeca5ef19fc6.jpeg)

 ![Split](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/f/15fd1cb267b90710784556c508df2589ab8e556d.jpeg)

**Shell sort strings:**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/2/372935b17464266b5764109a3d3a04eaac8c6ed3.png)

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 25, 2023, 9:28am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/5 "2023-04-25T09:28:19Z")

</div>

**SORT ACTORS**

To sort any objects, we need to compare them by some parameter. Let’s first try to sort the actors by name.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/f/8ff64333cd3b437014d8cfe571d582f4ef79ea87.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/4/3044d3abb7ede7b09d07c1d0c5f373c9b6cddcf0.png)

You can also choose any other criterion for comparison. If you need a function to sort objects according to various parameters, you can create many comparison functions and select them by passing some key, for example, Enum.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/7/bd727839bfb6af4ef751480cfe8db51b753b8a9d.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/3/f3389d4d75d0219f358483705e425bf4f534d9a3.png)

**Example:**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/c/41cad7b61fb94230bca29cc5f2e22eb69060f8fa.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/7/b47fd0417758c2fb9bc80a6fa402621c8bc7d35d.png)

---

<div class="post-metadata">

**Author:** ![xeoncat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xeoncat/32/1140479_2.png) [@xeoncat](https://forums.unrealengine.com/u/xeoncat)\
**Post date:** [April 25, 2023, 6:03pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/6 "2023-04-25T18:03:00Z")

</div>

This is the greatest thing ever and don’t let anyone tell you otherwise

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 26, 2023, 7:34am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/7 "2023-04-26T07:34:07Z")

</div>

**Improved Shellsort**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/c/68cc8df82a03b4b81edb569b63dd1057b19d1ae6.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/3/7d329008afb1fd070589b5e6fa30150e55620fb4.png)

In this study, I implemented Shell sort with a simple selection of gaps. The average running time of the algorithm depends on the lengths of the intervals - d, which will contain the sorted elements of the original array with a capacity of N at each step of the algorithm. There are several approaches to choosing these values, and I selected Marcin Ciura’s empirical sequence.

![StatFloatsFuncCiur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/4/43471ed773fb168b9c8eadd16e09d646d101aeba.png)

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 27, 2023, 6:30am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/8 "2023-04-27T06:30:56Z")

</div>

> **[Heapsort](https://en.wikipedia.org/wiki/Heapsort)**
>
> In computer science, heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like selection sort, heapsort divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region. Unlike selection sort, heapsort does not waste time with a linear-time scan of the unsorted region; rather, heap sort maintains the unsorted region in a h...

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/8/4784b077f4df37d0926c92b4b8d19ee867bee7ab.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/6/6765ccbc8ac3c818624d4ca0f97b3da1c8c9a2b2.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/4/6f411c1290d214599466a6cc91dd975ef2d65c5e.png)

![StatFloatsFuncHeap](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/6/5f6e94680a70d4b8dd026b9a5c60963ebf641900.png)

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [April 28, 2023, 5:23pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/9 "2023-04-28T17:23:21Z")

</div>

I found a small mistake in my implementation of the improved Shellsort. Fixed the function and statistics.

---

<div class="post-metadata">

**Author:** ![Jaroslaw\_Piszcze](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jaroslaw\_Piszcze](https://forums.unrealengine.com/u/Jaroslaw_Piszcze)\
**Post date:** [January 3, 2025, 5:54pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/10 "2025-01-03T17:54:34Z")

</div>

Hi, I can’t compare two strings using Greater Than node in UE 5.5. What is the workaround?

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [January 5, 2025, 8:29am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/11 "2025-01-05T08:29:55Z")

</div>

Are you sure you are using this func?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/1/fb1da05a8d591996b034bd5872862daf576be1bd.png)

---

<div class="post-metadata">

**Author:** ![tootzoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tootzoe1](https://forums.unrealengine.com/u/tootzoe1)\
**Post date:** [January 5, 2025, 8:49am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/12 "2025-01-05T08:49:27Z")

</div>

hi , could you tell me what’s the value of Factor node? i didn’t find where it was defined?

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [January 5, 2025, 9:29am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/13 "2025-01-05T09:29:17Z")

</div>

This is a local variable. Value = 1.247331

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/d/3/2d350b407593b264f6b40b9360bdf4ad9b415bac.png)

---

<div class="post-metadata">

**Author:** ![tootzoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tootzoe1](https://forums.unrealengine.com/u/tootzoe1)\
**Post date:** [January 5, 2025, 1:55pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/14 "2025-01-05T13:55:38Z")

</div>

Thanks @Supremative , after setting this value properly , the ActorsSort routine works like a chains 👍

---

<div class="post-metadata">

**Author:** ![tootzoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tootzoe1](https://forums.unrealengine.com/u/tootzoe1)\
**Post date:** [January 12, 2025, 12:31pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/15 "2025-01-12T12:31:21Z")

</div>

I added some UI for better visualization

![Sequence 01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/5/d852154046af04cfa17e1ba37e1448d5aed749c5.gif)

> **[GitHub - tootzoe/SortingAlgorithms: UE SortingAlgorithms , including some Sorting...](https://github.com/tootzoe/SortingAlgorithms)**
>
> UE SortingAlgorithms , including some Sorting Algorithms implemented in blueprint....

---

<div class="post-metadata">

**Author:** ![GN\_Snows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GN\_Snows](https://forums.unrealengine.com/u/GN_Snows)\
**Post date:** [January 13, 2025, 4:26pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/16 "2025-01-13T16:26:48Z")

</div>

Thanks a lot!! I’m a beginer and was stuck for hours trying to sort an array… found your post and it worked in minutes! Thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![Jesse\_Sound](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jesse_sound/32/1028163_2.png) [@Jesse\_Sound](https://forums.unrealengine.com/u/Jesse_Sound)\
**Post date:** [February 11, 2025, 2:22pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/17 "2025-02-11T14:22:30Z")

</div>

Howdy.

I recently just implemented Radix sorting.

I havent tested anything crazy yet, forgive me. No statistics. But feel free to take what I’ve made and try bigger arrays! Small chance I’m not sharing enough information, but feel free to reach out and I can dive deeper with you.

I’m a new user so I can’t share the other screenshots in the same post, but a quick description:

A function named Radix sort that takes in the Max Value of an array, the array it’s self, and the length of the array (I know we can find the length whenever we want, but this makes it cleaner)

Then we have a custom for loop macro that starts atindex 1 and loops until I \< Max Value, with i being multiplied by 10 each loop. to which we call the modified counting sort algorithm, taking in Array, Length, and the index from the custom loop macro.

 ![Screenshot 2025-02-11 004502](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/9/7/19734edfaa57172345b756566204e95ce2fe23f1.png)

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [February 12, 2025, 10:53am UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/18 "2025-02-12T10:53:53Z")

</div>

> **[Radix sort](https://en.wikipedia.org/wiki/Radix_sort)**
>
> In computer science, radix sort is a non-comparative sorting algorithm. It avoids comparison by creating and distributing elements into buckets according to their radix. For elements with more than one significant digit, this bucketing process is repeated for each digit, while preserving the ordering of the prior step, until all digits have been considered. For this reason, radix sort has also been called bucket sort and digital sort.
> Radix sort can be applied to data that can be sorted lexico...

Has a time complexity of O(nk), where n is the number of elements and k is the number of digits in the numbers.

**When to use Radix Sort:**

- Radix Sort is particularly useful for sorting a large number of integers where the number of digits is relatively small.
- Suitable for sorting fixed-length strings, such as codes or identifiers.
- It may be less effective for data with a wide variation in digits or for long strings where k approaches n.

---

<div class="post-metadata">

**Author:** ![Jesse\_Sound](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jesse_sound/32/1028163_2.png) [@Jesse\_Sound](https://forums.unrealengine.com/u/Jesse_Sound)\
**Post date:** [February 13, 2025, 10:53pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/19 "2025-02-13T22:53:34Z")

</div>

Thanks for adding! Epic wouldn’t let me share too much given it being my first comment

---

<div class="post-metadata">

**Author:** ![DentonJC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DentonJC](https://forums.unrealengine.com/u/DentonJC)\
**Post date:** [March 25, 2025, 5:31pm UTC](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992/20 "2025-03-25T17:31:58Z")

</div>

legendary comment right here

[Next page](https://forums.unrealengine.com/t/sorting-algorithms-in-blueprints/1135992.md?page=2)
