playMaker

Author Topic: Sorting XML  (Read 1052 times)

Zenfish

  • Playmaker Newbie
  • *
  • Posts: 13
Sorting XML
« on: March 14, 2020, 07:13:14 AM »
Hi,

I'm currently playing with Datamaker and I was wondering if there any trick/method(array?)/action to sort XML result.
Seems it's unfortunatly impossible to sort using xPathquery...

For exemple:
Code: [Select]
<ITEM id="1" categorie="sword" name="Cool Sword" price="3" pwr="2">/ITEM>
<ITEM id="2" categorie="axe" name="Super axe" price="5" pwr="3"></ITEM>
Using following action: XML Select Node->Xml Get Next Node List Properties and then iterate a game object to get a list with name, price and PWR.
I would love now to be able to sort these iterations by name, price or pwr.(create a table where i can sort columns)


Thanks!


« Last Edit: March 14, 2020, 03:08:12 PM by Zenfish »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sorting XML
« Reply #1 on: March 17, 2020, 04:49:30 AM »
Hi,

 for this kind of sorting, here's what I do.

 I create a hashtable for each column, where the key is the ID value ( as a string)

then on the column you want to sort, extract the values from the hashtable, into am arraylist, sort that, and then you can look up the key for that value, and with that key, get all the rest of the row.

 Bye,

 Jean

Zenfish

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Sorting XML
« Reply #2 on: March 17, 2020, 12:28:11 PM »
Thanks Jean!

I'll try this. It will be my challenge of the week :)

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Sorting XML
« Reply #3 on: February 10, 2023, 03:17:49 PM »
Hi,

 for this kind of sorting, here's what I do.

 I create a hashtable for each column, where the key is the ID value ( as a string)

then on the column you want to sort, extract the values from the hashtable, into am arraylist, sort that, and then you can look up the key for that value, and with that key, get all the rest of the row.

 Bye,

 Jean

Hi.

I was wondering if this is still the best solution to sort xPathquery results?
Are the any other solutions out there?

Thanks!