Christine Stringfield
Posts: 0
Joined: Wed Apr 03, 2013 4:35 am

Sorting results from Facebook Graph API

I am trying to retrieve a list of Facebook friends, and I would like them to be in alphabetical order. The Facebook Graph API returns an array like so:

{
"data": [
{
"id": "12345",
"name": "Jane Doe"
},
{
"id": "56789",
"name": "Elizabeth Doe"
}
]
}

This is in no apparent order. Any suggestions for how I can sort this?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Sorting results from Facebook Graph API

Check if Facebook API provides an option to sort the result. The other option would be to sort the resulting data on the client.

Christine Stringfield
Posts: 0
Joined: Wed Apr 03, 2013 4:35 am

Sorting results from Facebook Graph API

I figured it out using the Facebook Query Language:

I have to use the following URL for the REST request:

http://graph.facebook.com/fql?q=SELECT uid, name, pic, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name

Return to “Issues”