You can fetch the albums and then iterate through them to populate a song array, resulting in the songs sorted with respect to the albums:
NSMutableArray *sortedSongs = [[NSMutableArray alloc] init];
MPMediaQuery *albums = [MPMediaQuery albumsQuery];
NSArray* albumObjects = [albums collections];
for(MPMediaItemCollection *album in albumObjects) {
for(MPMediaItem *song in album.items) {
[sortedSongs addObject:song];
}
}
NSLog(@"sorted songs : %@", sortedSongs);
Hope this helps