Selecting and sorting data JSON

  arrays, filter, javascript, json, sorting

I need to develop simple app to select and sort data from JSON list, containing two rules – "include" and "sort_by"

Example:
input data:

{"data": [{"name": "John", "email": "[email protected]"},
          {"name": "John", "email": "[email protected]"},
          {"name": "Jane", "email": "[email protected]"}]}

condition:

{"condition": {"include": [{"name": "John"}], "sort_by": ["email"]}}

output:

{"result": [{"name": "John", "email": "[email protected]"},
            {"name": "John", "email": "[email protected]"}]}

Source: Ask Javascript Questions

LEAVE A COMMENT