# Sorting JSON output correctly

**URL:** <https://forum.ansible.com/t/sorting-json-output-correctly/29895>\
**Category:** Ansible Project\
**Created:** [March 15, 2019, 7:00pm UTC](https://forum.ansible.com/t/sorting-json-output-correctly/29895 "2019-03-15T19:00:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![email](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@email](https://forum.ansible.com/u/email)\
**Post date:** [March 15, 2019, 7:00pm UTC](https://forum.ansible.com/t/sorting-json-output-correctly/29895/1 "2019-03-15T19:00:09Z")

</div>

Hey all, I have a task that I’m really struggling to convert into Ansible from Python.

I’m uring the uri module to query an API and it returns the JSON output like the following:

`

[  
{  
“Name”: “Linux File System”,  
“Task”: “Succeeded”,  
“Date”: “epochdate”  
},  
{  
“Name”: “DB System”,  
“Task”: “Succeeded”,  
“Date”: “epochdate”  
},  
{  
“Name”: “Linux File System”,  
“Task”: “Succeeded”,  
“Date”: “epochdate”  
},  
{  
“Name”: “DB System”,  
“Task”: “Succeeded”,  
“Date”: “epochdate”  
}  
]

`

So a simple list of dicts…

However, the list will have two different types of `Name` in them, and these aren’t in order.

I can currently print out the JSON with the following:

`

- debug:  
msg: “{{ data.json[‘items’] }}”

`

The outcome I am looking for is something like this:

`  
Linux File System Succeeded Date

Linux File System Succeeded Date

Linux File System Succeeded Date

DB System Succeeded Date

DB System Succeeded Date

DB System Succeeded Date  
`

So effectively split them into two separate groups.

I can do this with python just fine, however, I don’t seem to be able to grasp how to convert this into Ansible.

Can anyone put me on the right track here?

Thanks in advance!
