# Alternate sort on a bidimensional array

**URL:** <https://discourse.processing.org/t/alternate-sort-on-a-bidimensional-array/19698>\
**Category:** Coding Questions\
**Created:** [April 12, 2020, 2:48pm UTC](https://discourse.processing.org/t/alternate-sort-on-a-bidimensional-array/19698 "2020-04-12T14:48:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quorum](https://avatars.discourse-cdn.com/v4/letter/q/ad7895/32.png) [@Quorum](https://discourse.processing.org/u/Quorum)\
**Post date:** [April 12, 2020, 2:48pm UTC](https://discourse.processing.org/t/alternate-sort-on-a-bidimensional-array/19698/1 "2020-04-12T14:48:43Z")

</div>

Hi there 🙂

I’m an absolute beginner in processing and I’ve not found on the references this answer.  
Can I apply an alternate sort to a bidimensional array? As 0, 1, 0, 1…

There is a standard function for this or I have to do it manually?  
For example in matlab I can do a minimum sorting considering a specific vector element calling a variable into the index of the array like in vectorElem(index) from this code

```auto
 m = vectElem(1);
    indexMin = 1;
    for index=1:length(vectorElem)
        if vectorElem(index) < m
            m = vectorElem(index);
            indexMin = index;
        end
    end

```

Because I’ve tried and I get an error

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 12, 2020, 2:56pm UTC](https://discourse.processing.org/t/alternate-sort-on-a-bidimensional-array/19698/2 "2020-04-12T14:56:40Z")

</div>

By bidirectional I assume you mean a 2D array?

The code you post appears to find the smallest value in a vector (1D array) and its index position in the vector.

You need to explain yourself more clearly 🙂
