Request Sort Array Descending

Discussion and feedback on Construct 2

Post » Thu Dec 18, 2014 2:47 pm

Can you really only sort arrays in ascending order? Or is there other ways people get around this?

I have a 2D array with 7 rows:

Score, TeamName

and I want to sort so the highest score is at the top.. then I can print to the screen

Sort(X)
For each Element
Append Text = Array(CurX,1) & Array(CurX,0)

*this will print TeamName and their score but in ascending order - meaning the lowest score will be at the top! And while this might be good for a golf game, it's not what I need.

I know I can do a For Loop and set it to loop backwards.. and that's how I got it to work.. but I can think of situations where I'd need this array sorted in descending order. Do I have to breakout my bubble or btree sort and convert it into C2? ;)
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Thu Dec 18, 2014 11:48 pm

Can't you use Sort and Reverse together?

capx:

https://www.dropbox.com/s/59hs3a7n8e030 ... .capx?dl=0
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Fri Dec 19, 2014 3:08 am

@TiAm That was what I was missing! thank you..

it's not that intuitive since it doesn't even mention a Sort order in the dialogue box.. and checking the manual it mentions ascending only.. strange to have it be a whole different Action.

A little bit cludgey.. but it'll work!
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Fri Dec 19, 2014 2:10 pm

My guess would be that it (the for each element) has been designed to be used to to change values inside the array not based on the values of other cells, still a valid request IMO.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Wed Dec 24, 2014 5:16 am

@Aphrodite yeah, I'd like to see a Ascending/Descending dropdown added to the Action dialogue box...
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003


Return to Construct 2 General

Who is online

Users browsing this forum: Cliffu, dwtiger and 1 guest