Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Help sorting array of structs


I'm trying to make a function to sort an array of structures by one of its members value (a float), from lowest to highest. This is what I have so far:


I thought this would work fine, but it doesn't, and I'm unable to figure out why... Instead of returning the sorted array, the function just returns an array with the same size of the input array, but with the same item -the one with lowest value- repeated.

What am I missing?

Thank you very much in advance! :)

Product Version: UE 4.14
sortarray.png (417.9 kB)
more ▼

asked Mar 06 '17 at 08:21 AM in Blueprint Scripting

avatar image

88 4 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This should fix it. Every time you have a node connected to the MinOfArray node, it is calling it again, and so getting a different value after the min has been removed. If you store the first value it gets each loop, you will avoid this problem:

alt text

screenshot_2.jpg (661.5 kB)
more ▼

answered Mar 06 '17 at 10:54 AM

avatar image

1.8k 49 22 67

avatar image MyIvoryTower Mar 06 '17 at 11:35 AM

Life-saver! Yeah, that works like a charm! ^^

Thank you SO much! I owe you a drink, haha!

avatar image w0hoho Jul 17 '18 at 08:05 PM

I made this a simply function and call it after adding something to array but it didn't work. How should I use it?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

It's also worth mentioning that Rama's Victory Plugin has a Sort node for arrays, and an option to sort by structure or object field. Works fine for me.

more ▼

answered Mar 21 '18 at 05:05 PM

avatar image

91 2 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question