title: Optimized data sort - software r
body: <p>this is my first post, so please be polite if I might get sth wrong. </p>
  
  <p>I have a set of data that I want to sort in a specific way using the software r.<br>
  It is a non-quadratic matrix of tasks (>100) that require specific components (>100) of specific material (1, 2, 3, or 4). I want to figure out, which tasks can be executed as a group because they require the same components. That's easy. But I want to optimize it, means that components with a low-value material (1) can be "upgraded" to a higher value material (2, 3 or 4) if that decreases the number of groups.<br>
  I could only manage to sort the data while upgrading all materials, but that's not what I want. </p>
  
  <p>My minimum example looks like this:</p>
  
  <pre><code>1 0 0 2 0 4 0  
  2 2 4 0 0 1 1  
  0 4 4 0 0 3 0  
  1 3 0 1 1 0 4  
  4 2 1 0 4 1 2 
  </code></pre>
  
  <p>0 means that this component is not required. </p>
  
  <p>I hope I could describe my problem clearly enough.<br>
  thanks a lot in advance for your suggestions<br>
  Miguel</p>