`import json, algorithm let j = parseJson"""[{"id":"5","name":"A"}, 
{"id":"6","name":"C"}, {"id":"3","name":"B"}]""" let x = j.getElems.sorted(proc 
(a, b: JsonNode): int = cmp(a["name"].getStr, b["name"].getStr)) echo x # 
@[{"id": "5", "name": "A"}, {"id": "3", "name": "B"}, {"id": "6", "name": "C"}] 
`

Run

Reply via email to