I have a 2d array with four columns (lettered A--D) and each column has three rows. Here is a visual representation of my array:
A B C D
1 3 9 0
2 8 2 1
8 4 10 3
I want to sort the columns by the smallest number in each column. This is how I want my array to look after sorting:
D A C B
0 1 9 3
1 2 2 8
3 8 10 4
The D column is first because the smallest number in the column is 0
, and 0
is the smallest among all columns' smallest numbers. A is next because the smallest number in A is 1
, and 1
is smaller than 2
(the smallest number in column C) and 3
(the smallest number in column B).
Any help would be appreciated.