Sort Array Alphabetically (Solved)

Discussion and feedback on Construct 2

Post » Fri Nov 22, 2013 8:08 pm

Is it possible to sort the contents of an array alphabetically using events? If not, can this action be added to the array object? All I've been able to find is numerical sorting.MadFactory2013-11-23 03:24:10
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Fri Nov 22, 2013 8:11 pm

I've been after this too - eventually I started on a system that transferred all the letters to a number value using expressions, but realised it would take more work than I was willing to do for it. Let me know if you find something!
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Fri Nov 22, 2013 9:07 pm

The built in Array.Sort does support strings.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Fri Nov 22, 2013 9:08 pm

lol oh..I didn't think about it that way ^^; Be right back.

Edit: Yep that works.MadFactory2013-11-23 00:12:36
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Fri Nov 22, 2013 10:54 pm

Well aren't I feeling silly ^^ Thanks for bringing it to my attention.
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Sat Nov 23, 2013 12:10 am

Hm. Looks like it only sorts the first Z dimension. I need to sort the X axis on all dimensions individually. Is this possible? (I suppose I could use multiple arrays instead but I'd rather just use the one.)MadFactory2013-11-23 00:11:42
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Sat Nov 23, 2013 12:32 am

Have you tried for each xyz?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
93
S
30
G
22
Posts: 1,987
Reputation: 20,203

Post » Sat Nov 23, 2013 12:52 am

Yeah it doesn't change anything.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Sat Nov 23, 2013 12:59 am

Try CSV ( or CVS ) object. You could try transfering data from array, sort it and the return it to array sorted.megatronx2013-11-23 01:03:20
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
93
S
30
G
22
Posts: 1,987
Reputation: 20,203

Post » Sat Nov 23, 2013 1:06 am

Thats because Construct 2 "runs" in the direction x -> some y -> even more z

sorting by x will move x, y and z (because it checks for array.at(index) when sorting)
sorting by y will move y and z and leave x in place
sorting by z will move z and leave x and y at place

so to do what you want, use x as your page index and y and z as your 2 dimensional data table. (you can create a new array and fill it with for each xyz oldarray: set newarray at(oldarray.curz,oldarray.curx,pldarray.cury) to oldarray.curvaluemindfaQ2013-11-23 01:10:12
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests