title: Opencv function equal for matlab sortrows
body: <p>I have an 2D array type <code>Mat</code> in my Android OpenCV project, and I need to sort the array in the same manner as the MATLAB <code>sortrows</code> function. I found the <code>Core.sort()</code> function that takes flags like <code>Sort_Every_Row</code>.  This seems to be the one I want, but when I use this method I get different output results from the ones I get from MATLAB.</p>
  
  <p>Is there any other function, or any other ways to do this kind of sort? Do I have to write the method from scratch?</p>
  
  <p>Below is the line I use for sorting my array FeatureMatirx : </p>
  
  <pre><code>Core.sort(FeatureMatrix, FeatureMatrix, Core.SORT_EVERY_ROW);
  </code></pre>
  
  <p>Edit : 
  Let Me Explain With A Simple Example:</p>
  
  <pre><code>Mat test = new Mat(4,3, CvType.CV_64FC1);
  test.put(0, 0, 1);
  test.put(0, 1, 2);
  test.put(0, 2, 3);
  test.put(1, 0, 1);
  test.put(1, 1, 1);
  test.put(1, 2, 1);
  test.put(2, 0, 2);
  test.put(2, 1, 1);
  test.put(2, 2, 3);
  test.put(3, 0, 1);
  test.put(3, 1, 2);
  test.put(3, 2, 1);
  
  Core.sort(test, test,Core.SORT_EVERY_ROW + Core.SORT_ASCENDING);
  
  for (int k = 0; k &lt; test.rows(); k++) {
      Log.i("Test", test.get(k, 0)[0] + " " + test.get(k, 1)[0]+ " " +test.get(k, 2)[0]);
  }
  </code></pre>
  
  <p>and the result of above example is this: </p>
  
  <pre><code>03-05 21:32:01.893: I/Test(1323): 1.0 2.0 3.0
  03-05 21:32:01.893: I/Test(1323): 1.0 1.0 1.0
  03-05 21:32:01.893: I/Test(1323): 1.0 2.0 3.0
  03-05 21:32:01.893: I/Test(1323): 1.0 1.0 2.0
  </code></pre>
  
  <p>but sortrows in matlab result as below:</p>
  
  <pre><code>1     1     1
  1     2     1
  1     2     3
  2     1     3
  </code></pre>