Article - CS391149

How to sort a JSON array based on one particular field of the JSON object of the array with javascript in Vuforia Studio

Modified: 20-Apr-2023   


Applies To

  • Vuforia Studio 9.0.0 to 9.8.0

Description

  • How to sort a JSON array based on one particular field of the JSON object of the array with javascript
  • E.g: I have a JSON array with value below, how can I sort the array based on the name field and get ascending or descending result based on my requirement
[{
    "name":"c","value":"c.txt"}
                   ,{
                     "name":"a","value":"a.txt"}
                   ,{
                     "name":"b","value":"b.txt"}
                   ,{
                     "name":"123","value":"123.txt"}
                   ,{
                     "name":"234","value":"234.txt"}
                   , {
                     "name":"d", "value":"d.txt"}
                  ];
This is a printer-friendly version of Article 391149 and may be out of date. For the latest version click CS391149