Count appearances of a value in a structure

zuvala's picture

hi there

Is it possible to detect how many times a value is repeated within a structure? ie. i've got a xml-file with a "date" key and want to create several individual representations grouped for each day.

Or divide a structure in several substructures, when a key value changes?

thanks for any advice

String to integer using javascript

Swiftlikeninja's picture

Okay I ran into an interesting scenario trying to sort through an xml feed. The Structure I have has a number of completes field and Im trying to get a leaderboard set up with the top completes displayed but the feed has the completes as a string and as such the structure sort sorts them alphabetically. Meaning that 10 would actually come before 2 which can cause some major issues in sorting. I found that if I use a number splitter off the complete index and rebuild the structure w/ the kineme structure maker then sorting works but the structure Im using can range to over 400 members so manually doing this is out of the question and i don't think iterator is the answer. Can anyone assist me in a javascript answer on how to change a substructure in an entire structure list from a string to an integer?

Or even simpler, tell me if Im missing something in the structure sort?

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

Search results now has sort and filter, yeh!'s picture

So I was searching for cybero's recent post on ATI GPU cards and noticed the new sort and filter sidebar fucntions that list with the search results. Very cool enhancement, smokris! This will help me heaps when racking my memory bank.

Noticed a few little issues, like despite getting close to majority of hits being authored by cybero, in the filter by author list he isn't listed. At a couple of authors are just listed by the hit number ie: (9) and (3) not gtoledo_(9) leegrosbauer_(3). Also smokris is getting multiple listings (14),(10),(3)&(2)… I guess that's no big deal.

Be good if hits could be generated on comment author not just topic 'OP' author. Think you mentioned this is a limitation of the Drupal module or something. Perhaps I haven't investigated fully too.

Sorting arrays and splitting arrays in Javascript's picture

Javascript help for novice coders like me!

Apart from the fact that the JS patch is temperamental — requiring restarts of QC application when it will not parse good script — I attempted to clear up some of the mysteries I had around working with 2D datasets in Javascript. Standard JS array methods that work for 1D arrays often don't work for more complicated array structures.

This composition has three demo JS patches for:

splitting a set of points into two sets (odds and evens by index), sorting an array of dictionaries by a common dictionary key (a-Z) & concatenating both internally created and inputed structures into one array

All the code is well commented, I hope it can save some of the suffering for others that the JS patch has given me. So let me know if it does and I will have been rewarded for posting it.