title: Sort NSArray with custom objects
body: <p>In my Xcode project I have the following classes:</p>
  
  <p><strong>Address</strong></p>
  
  <pre><code>@interface LDAddress : NSObject{
      NSString *street;
      NSString *zip;
      NSString *city;
      float latitude;
      float longitude;
  }
  
  @property (nonatomic, retain) NSString *street;
  @property (nonatomic, retain) NSString *zip;
  @property (nonatomic, retain) NSString *city;
  @property (readwrite, assign, nonatomic) float latitude;
  @property (readwrite, assign, nonatomic) float longitude;
  
  @end
  </code></pre>
  
  <p><strong>Location</strong></p>
  
  <pre><code>@interface LDLocation : NSObject{
      int locationId;
      NSString *name;
      LDAddress *address;
  }
  @property (readwrite, assign, nonatomic) int locationId;
  @property (nonatomic, retain) LDAddress *address;
  @property (nonatomic, retain) NSString *name;
  
  @end
  </code></pre>
  
  <p>In an subclass of UITableViewController, there is a NSArray containing a lot of unsorted objects of LDLocations. Now, I want to sort the NSArray's objects ascending based on the property <em>city</em> of a LDAddress.</p>
  
  <p>How can I sort the array using NSSortDescriptor?
  I tried the following, but the app dumps when sorting the array.</p>
  
  <pre><code>NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Address.city" ascending:YES];
  [_locations sortedArrayUsingDescriptors:@[sortDescriptor]];
  </code></pre>