How do I sort an array (as values are removed upon sort)

0 favourites
  • 5 posts
From the Asset Store
Customize the animation of character when item changed
  • Hi,

    So I have built an array, and populated it with the data I require, I then want to sort the array, however when I do this the second record in the array is removed. It is the same row every time.

    See screenshot for details. As you will see the unsorted array has a value of "1-06" in row 1, once the array is sorted this value is dropped, and the rest of the array sorts correctly.

    As above this issue consistently happens with the exact same behaviour each time.

    I am using arrayname Sort X Axis as the action.

    If I reverse the array, then the data is retained, but row 0 is then not sorted - what am I doing wrong?:-

    Thanks in advance again! :)

    Tagged:

  • Looks to me like a bug with sorting string values. If you can reproduce it in a small project, you should report it:

    github.com/Scirra/Construct-3-bugs/issues

  • Tested it myself with c2 and c3 and it's sorting correct with that data you're using.

    dropbox.com/s/dz762jh9t0myg9a/array_sort_test.capx

    You'll have to show your project or events.

  • Tested it myself with c2 and c3 and it's sorting correct with that data you're using.

    https://www.dropbox.com/s/dz762jh9t0myg9a/array_sort_test.capx?dl=1

    You'll have to show your project or events.

    Thank you so much, I looked at your example and replicated it in my project, it failed on the first line, which demonstrated the issue was with the order in which I built my array.

    When I went back to look I could see I had added the first line outside of the main function call, so it was getting updated after the sort had happened.

    Thanks for the pointer as it also taught me a neat way to output the contents of an array really cleanly!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Cool, glad it was useful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)