title: iPhone memory leak and release problem on sorted array
body: <p>I'm having some troubles with the code below:</p>
  
  <pre><code>NSSortDescriptor *idDescriptor = [[[NSSortDescriptor alloc] initWithKey:key ascending:ascending] autorelease];
  NSArray *sortDescriptors = [NSArray arrayWithObject:idDescriptor];
  NSArray *orderArray = [array sortedArrayUsingDescriptors:sortDescriptors];  
  NSMutableArray *result = [NSMutableArray arrayWithArray:orderArray];
  </code></pre>
  
  <p>If I use this code, Instruments says I have a memory leak, why?</p>
  
  <p>Using this code:</p>
  
  <pre><code>NSSortDescriptor *idDescriptor = [[[NSSortDescriptor alloc] initWithKey:key ascending:ascending] autorelease];
  NSArray *sortDescriptors = [NSArray arrayWithObject:idDescriptor];
  NSArray *orderArray = [array sortedArrayUsingDescriptors:sortDescriptors];
  
  NSMutableArray *result = [[NSMutableArray alloc] initWithArray:orderArray];
  </code></pre>
  
  <p>I receive the leak warning too, however, if I autorelease the object result, a memory error happens.</p>