I have created a multidimensional array (slice) in Go as follows:
var distancematrix [5][5]int
So it is a 5*5 array/slice. Now I am inserting values into this slice such that at a point:
distancematrix : [[0 154 12 35 138] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0]]
Now, I want to sort this array in ascending order, e.g.:
sorteddistancematrix : [[0 12 35 138 154] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0]]
I tried sort.Ints(distancematrix[0])
but it throws an error saying:
cannot use distancematrix[0] (type [5]int) as type []int in argument to sort.Ints
Basically, I want to fetch the smallest non-zero value in the array. How can I sort this array to achieve this?