Sorting a structure

Swiftlikeninja's picture

Okay, I have been trying to wrap my head around javascript to no avail so i call upon the assistance of the masses here at kineme. I dont know if just the structure sort patch will do what i need but in essence, i'm building a scoreboard display that will display individuals and team scores. What I would like assistance in is figuring out a way to sort a structure of based upon a substructure. If you look at the attached png as an example, i would like to be able to sort the entire structure by team name preserving the keys and structure layout.

once i figure this out my next task will be separating each team into its own structure.

If anyone could point me in the right direction I would be eternally grateful. I have tried to dig through all the javascript references on the kineme site and cyberos guide and my mind just explodes.

If I could just learn javascript i would be in heaven! :P

PreviewAttachmentSize
structure.png
structure.png202.45 KB

Swiftlikeninja's picture
Re: Sorting a structure

I got the structure sort patch figured out ( I wasnt going far enough into the sub structure to sort by key. I was overlooking the : as the depth determiner)Now to tackle the issue of creating the individual structures based around team name.

EDIT* I fleshed out my thought process on the individual structure base around team name but again I am lost in java.

I have

Function (__structure results) main(__structure Input) Take structure (input) key (teamName) If Team name = insert conditional then add to new array loop through structure and do same for every instance return results as new array

The structure that I will be going through is 400+ members long and I'm trying to flesh it down to just a 22 member array. (Each team has 22 people) I can then just duplicate the java patch and change the variables to make the next team structure. Again any assistance is greatly appreciated. Im been trying to bounce this idea around to anybody I can.

Thanks in advanced.

dust's picture
Re: Sorting a structure

so yeah i find the structure sort patch to be very useful. one trick i do lets say in a musical context is have two structures one with my values lets numbers and then with my keys stored as values so you can display lets say the key c with the note number or something.