Is this code the best way to Sort Json (Later I want to replace that Data List with a Property, But I am trying to figure out the best way top sort it.
[h: data = json.evaluate('{"Backpack":{"Amount":1,"Store":1,"Weight":1},"Traveling Clothes":{"Amount":1,"Store":1,"Weight":2},"Waterskin":{"Amount":1,"Store":1,"Weight":0.25},"Glowstone":{"Amount":1,"Store":1,"Weight":0.1},"Healing Potion":{"Amount":0,"Store":0,"Weight":0.1},"Lucky Rabbits Foot":{"Amount":1,"Store":1,"Weight":0.1},"Golden Idol":{"Amount":1,"Store":1,"Weight":0.25},"Katana":{"Amount":1,"Store":1,"Weight":4},"Kapi Coins":{"Amount":5,"Store":1,"Weight":0.25},"Copper Ring":{"Amount":1,"Store":1,"Weight":0.1},"Magic Elixer":{"Amount":3,"Store":1,"Weight":0.1},"Choker ofCommunication":{"Amount":1,"Store":1,"Weight":0.1},"Book on Ancient Tantric Sex Tecniques":{"Amount":1,"Store":1,"Weight":1},"Silk Rope":{"Amount":2,"Store":1,"Weight":3},"Short Sword":{"Amount":1,"Store":1,"Weight":3},"Arcane Lance":{"Amount":0,"Store":1,"Weight":0},"Dagger":{"Amount":1,"Store":1,"Weight":2},"Bite":{"Amount":0,"Store":1,"Weight":0},"Claws":{"Amount":0,"Store":0,"Weight":0},"Vampire Serum":{"Amount":100,"Store":1,"Weight":0.01}}')]
[h: keys = json.fields(data)]
[h: list = ""]
[h, foreach(k, keys), code:
{
[h: item = json.get(data, k)]
[h: weight = number(json.get(item, "Weight"))]
[h: list = list + weight + "|" + k + ";"]
}]
[h: sorted = listSort(list, "A", "N")]
[h: output = ""]
[h, foreach(entry, sorted), code:
{
[h: name = listGet(entry, 1, "|")]
[h: output = output + name + ", "]
}]
[r: output]