title: How to sort an NSMutableArray of objects by a member of its class, that is an int or float
body: <p>I have a class (from <code>NSObject</code>) that contains:</p>
  
  <pre><code>NSString name
  int      position
  float    speed
  </code></pre>
  
  <p>I then create an array (<code>NSMutableArray</code>) of objects from this class.  I would like to then sort the array by the 'speed' value, which is a <code>float</code>.</p>
  
  <p>I initially has the <code>float</code> value as an <code>NSNumber</code> and the <code>int</code> as <code>NSInteger</code>, and I was successfully sorting with:</p>
  
  <pre><code>[myMutableArray sortUsingFunction:compareSelector context:@selector(position)];
  </code></pre>
  
  <p>where <code>myMutableArray</code> is my array of objects.</p>
  
  <p>here is the function:</p>
  
  <pre><code>static int compareSelector(id p1, id p2, void *context) {
      SEL methodSelector = (SEL)context;
      id value1 = [p1 performSelector:methodSelector];
      id value2 = [p2 performSelector:methodSelector];
      return [value1 compare:value2];
  }
  </code></pre>
  
  <p>Now that I am using <code>int</code> instead of <code>NSInteger</code>, the above code does not work.  Is there a more low-level command that I should be using to execute the sort?  Thank!</p>