sort

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.

Updated go-rearrange and gorearrange to v102

go-rearrange and gorearrange were updated to v.1.0.2 From this version, data included multi-bytes characters can be used. At Linux, it works fine. At Windows DOS, rearranging and selecting data can be done. But the displayed data is shifted. Although this may be a bug of termbox-go, I don’t know the reason. I’m sorry. On the other hand, data with only single-byte characters works fine. About MAC, I don’t have it. If someone can confirm and tell me it, I’m glad.

Updated go-rearrange and gorearrange to v101

go-rearrange and gorearrange were updated to v.1.0.1 As one of outputs, indexmode (bool) was added. If this is true, the rearranged result is output as the change of index for the source data. For example, if the source data and rearranged data are ["a", "b", "c"] and ["c", "b", "a"], respectively. The output will become [2, 1, 0]. By this, the specification for creating applications will expand. The detail information and how to get this are https://github.

CLI Tool - gorearrange

Overview This is a CLI tool to interactively rearrange a text data on a terminal. Description Since I couldn’t find CLI tools for manually rearranging text data, I created this CLI tool. For this, at first, I created a Golang library go-rearrange. The detail information and how to get this are https://github.