I'm wondering if there is a better way to do this, work with pairs of numbers. I'm working through the problems on CodeAbbey. This one was
sort these numbers, then print out their original index location.
I did it like this. ( I'm still learning. )
public static void bSort(int[][] a) {
    boolean sorted = false;
    int temp;
    int temp2;
    while (!sorted) {
        int counter = 0;
        for (int i = 0; i < a.length - 1; i++) {
            if (a[i][0] > a[i + 1][0]) {
                temp = a[i][0];
                temp2 = a[i][1];
                a[i][0] = a[i + 1][0];
                a[i + 1][0] = temp;
                a[i][1] = a[i + 1][1];
                a[i + 1][1] = temp2;
                counter++;
            }
        }
        if (counter == 0) {
            sorted = true;
        }
    }
    for (int i = 0; i < a.length; i++) {
            System.out.print(a[i][1] + " ");
    }
}
I kept running into this as I was searching: Sort a Map<Key, Value> by values (Java) but I haven't worked with maps yet.
 
     
     
     
     
    