x

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"

Sorting an array based of a struct value

I saw a post about it and try to implement in my game but it didn't work. What am I doing wrong?

alt text

Product Version: UE 4.19
Tags:
arraysort.jpg (333.1 kB)
more ▼

asked Jul 18 '18 at 11:10 AM in Blueprint Scripting

avatar image

w0hoho
127 26 31 38

avatar image w0hoho Jul 26 '18 at 03:09 PM

Does anyone know any other way?

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

3 answers: sort voted first

I figured it out. After the 'while completed', I clear the first array, then set the new array to the first array.

more ▼

answered Jul 26 '18 at 05:34 PM

avatar image

w0hoho
127 26 31 38

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

Hi w0hoho, I've attached a working example of reordering a struct based on content values.

It's not necessarily the best way of doing it. The last node used needs to be a number appropriate to the scale of the values you're using. If your max value is 1000 then this needs to be something higher than that. (it's only used so that this array element is never chosen by "Min int of array")

Hope this helps

alt text

more ▼

answered Jul 19 '18 at 10:20 AM

avatar image

Unfathomable
481 2 5 7

avatar image w0hoho Jul 19 '18 at 02:56 PM

Thank you for your answer. I made it on my project but then I realized, it is not about the array. I add those cards to a scrollbox as child. They are not added by the cards array. I don't know how to sort the scrollbox.

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

It is almost always better to perform array manipulations in C++ rather than in Blueprints both in terms of performance and convenience so you might want to try sorting in C++.

As for your problem with scrollbox, you would need to retriveve the values of the cards from it and store them in the array, then sort the array as you do, clear the scrollbox and fill it with sorted values again.

Hope it helps

more ▼

answered Jul 20 '18 at 10:19 AM

avatar image

Hustlan
345 4 4 12

avatar image w0hoho Jul 21 '18 at 10:59 AM

I get values of the card but how do I connect the values with that scrollbox? Let's say I make an array of card values and then clear the scrollbox. Then, how do I add them based on that value?

avatar image Hustlan Jul 24 '18 at 05:24 AM

You mentioned that you add the cards to a scrollbox as children. When you need to sort them, you retrieve the children's value from the scrollbox, sort the values, clear the scrollbox and populate it again. Is it what you do not understand? Otherwise I did not quite get what is the problem.

avatar image w0hoho Jul 24 '18 at 11:07 AM

Yea that's it. I get the value now but array is not sorted. I tried so many ways.

(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