title: Sorted NSMutableArray from NSArray
body: <p>I have an <code>NSArray</code> called <code>message</code>, it contains an unsorted list of custom objects. Every object has the same structure, it has an <code>NSDictionary</code> and two other string in it. </p>
  
  <p>Every object is a message and i would like to sort them based on the dictionary key <code>keySenderUser</code> and <code>keyReceiverUser</code>. The new array should contain arrays, each array in the new array should represent the messages from a different user except the current user. </p>
  
  <p>For example i have 50 message in the base <code>message</code> array, it contains messages from Bill, John, Anna, Taylor and the "current user". I would like to put every message into a new array where John is the <code>keySenderUser</code> or <code>keyRecieverUser</code> and put to a new mutable array where i collect the messages of the users and do the same with Bill, John, Anna and Taylor. The result should be an array that looks like this:</p>
  
  <pre><code>NSMutableArray *messagesFromUsers = @[messagesOfBill, messagesOfJohn, messagesOfAnna, messagesOfTaylor];
  </code></pre>
  
  <p>For example the <code>messagesOfBill</code> must contains the messages where Bill is the sender or the receiver that we know from the dictionary values. If Bill is the sender, current user is the receiver, if Bill is the receiver, current user is the sender. The other part always is the current user. There is no messages where Anna is the sender and Bill is the receiver. </p>
  
  <p>As a first step i think i need a list with the usernames and then iterate through the all messages and create a new array for every user and collect these arrays into a new array, but honestly i don't have any idea how should i do it. I can remove objects from the message array based on one dictionary key, but that's all. I'm not experienced to figure it out alone.                  </p>
  
  <p>UPDATE:
  This is how one object looks like in the message array: </p>
  
  <pre><code>NSLog(@"First message: %@", [message objectAtIndex:0]);
  // result
      First message: PNMessage (0x175d49f0): &lt;message: {
          keyCreateDate = \"06/08/14 21:23\";             
          keyMessage = "Lorem Ipsum ";
          keyRecieverChannel = vidra;
          keySenderUser = currentUsersName;
      }, date: (null), channel: currentUsersName&gt;
  </code></pre>