# Android - Does OpenCV4Android support sortIdx?

I'm attempting to take this guide and modify it to get multiple matches : http://stackoverflow.com/questions/17...

So I started looking around since it seems like someone else would have done that. I came across Python examples using NumPY

```
result = cv2.matchTemplate(img,template,cv.CV_TM_SQDIFF)
#the get the best match fast use this:
(min_x,max_y,minloc,maxloc) = cv2.minMaxLoc(result)
(x,y) = minloc
#get all the matches:
result2 = np.reshape(result, result.shape[0]*result.shape[1])
sort = np.argsort(result2)
(y1, x1) = np.unravel_index(sort[0], result.shape) #best match
(y2, x2) = np.unravel_index(sort[1], result.shape) #second best match
```

and iOS examples and that brought me to cv::sortIdx.

```
C++: void sortIdx(InputArray src, OutputArray dst, int flags)
Python: cv2.sortIdx(src, flags[, dst]) → dst
Parameters:
src – input single-channel array.
dst – output integer array of the same size as src.
flags –
operation flags that could be a combination of the following values:
CV_SORT_EVERY_ROW each matrix row is sorted independently.
CV_SORT_EVERY_COLUMN each matrix column is sorted independently; this flag and the previous one are mutually exclusive.
CV_SORT_ASCENDING each matrix row is sorted in the ascending order.
CV_SORT_DESCENDING each matrix row is sorted in the descending order; his flag and the previous one are also mutually exclusive.
The function sortIdx sorts each matrix row or each matrix column in the ascending or descending order. So you should pass two operation flags to get desired behaviour. Instead of reordering the elements themselves, it stores the indices of sorted elements in the output array.
```

But I can't find any info on if there is a similar method for OpenCV4Android.

well, that was not so hard to find: http://docs.opencv.org/java/org/openc...

You rock man! Thanks.