summaryrefslogtreecommitdiff
path: root/sort.go
diff options
context:
space:
mode:
Diffstat (limited to 'sort.go')
-rw-r--r--sort.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/sort.go b/sort.go
index 4409eba..56b2fdd 100644
--- a/sort.go
+++ b/sort.go
@@ -5,6 +5,8 @@ import (
"io"
"os"
"strings"
+
+ "go.wit.com/log"
)
func makeSortfile() {
@@ -22,6 +24,21 @@ func makeSortfile() {
iterAppend(f, sortmap) // Append() enforce unique key argv.Append
}
+ for _, s := range uniqueKeys {
+ log.Info("found unique key in .proto", s)
+ sortmap["sortBy"] = s
+ sortmap["sortKey"] = s
+
+ iterSortBy(f, sortmap)
+
+ sortmap["append"] = sortmap["sortKey"]
+ iterAppend(f, sortmap) // Append() enforce unique key argv.Append
+
+ iterDelete(f, sortmap)
+ iterReplace(f, sortmap)
+ iterFind(f, sortmap)
+ }
+
for _, s := range argv.Sort {
sortparts := strings.Split(s, ",")
sortmap["sortBy"] = sortparts[0]
@@ -133,7 +150,7 @@ func iterSortAll(w io.Writer, names map[string]string) {
}
func iterSortBy(w io.Writer, names map[string]string) {
- fmt.Fprintln(w, "func (all *"+names["Bases"]+") Sort"+names["sortBy"]+"() *"+names["Base"]+"Iterator {")
+ fmt.Fprintln(w, "func (all *"+names["Bases"]+") SortBy"+names["sortBy"]+"() *"+names["Base"]+"Iterator {")
fmt.Fprintln(w, " packs := all.selectAll"+names["Base"]+"()")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " sort.Sort("+names["Base"]+""+names["sortBy"]+"(packs))")