Sorting for Slice using Golang
Gists This is a sample script for sorting a slice using Golang. Recently, I had a situation for sorting the coordinates of cells of Spreadsheet. As a test case, it thinks of the situation that the randomized cells are sorted. I think that this can be also used for a table except for Spreadsheet. Sample slice: The sample slice is as follows. ar := []struct { row int col int value string }{ {0, 0, "A1"}, {0, 1, "B1"}, {0, 2, "C1"}, {1, 0, "A2"}, {1, 1, "B2"}, {1, 3, "D2"}, {2, 0, "A3"}, {2, 2, "C3"}, } When each element of above slice is put to a Spreadsheet, it becomes as follows.