1package main 2 3import ( 4 "fmt" 5) 6 7func ExampleEditor_SortStrings() { 8 e := NewSimpleEditor(80) 9 e.InsertStringAndMove(nil, "example=(o a f g e b c d q h)") 10 currentLine := e.CurrentLine() 11 err := e.SortStrings(nil, nil) 12 if err != nil { 13 panic(err) 14 } 15 sortedLine := e.CurrentLine() 16 fmt.Println(currentLine) 17 fmt.Println(sortedLine) 18 // Output: 19 // example=(o a f g e b c d q h) 20 // example=(a b c d e f g h o q) 21} 22 23func ExamplesortStrings() { 24 inputString := "example=(o a f g e b c d q h)" 25 fmt.Println(inputString) 26 sorted, err := sortStrings(inputString) 27 if err != nil { 28 panic(err) 29 } 30 fmt.Println(sorted) 31 // Output: 32 // example=(o a f g e b c d q h) 33 // example=(a b c d e f g h o q) 34} 35 36func Example_sortStrings_2() { 37 inputString := "example={o a f g e b c d q h}" 38 fmt.Println(inputString) 39 sorted, err := sortStrings(inputString) 40 if err != nil { 41 panic(err) 42 } 43 fmt.Println(sorted) 44 // Output: 45 // example={o a f g e b c d q h} 46 // example={a b c d e f g h o q} 47} 48 49func Example_sortStrings_3() { 50 inputString := "example={\"o\" a 'f' g 'e' b \"c\" d 'q' h}" 51 fmt.Println(inputString) 52 sorted, err := sortStrings(inputString) 53 if err != nil { 54 panic(err) 55 } 56 fmt.Println(sorted) 57 // Output: 58 // example={"o" a 'f' g 'e' b "c" d 'q' h} 59 // example={a b "c" d 'e' 'f' g h "o" 'q'} 60} 61 62func Example_sortStrings_4() { 63 inputString := "o a 'f' g 'e' b \"c\" d 'q' h" 64 fmt.Println(inputString) 65 sorted, err := sortStrings(inputString) 66 if err != nil { 67 panic(err) 68 } 69 fmt.Println(sorted) 70 // Output: 71 // o a 'f' g 'e' b "c" d 'q' h 72 // a b "c" d 'e' 'f' g h o 'q' 73} 74 75func Example_sortStrings_5() { 76 inputString := `addKeywords = []string{"z", "--force", "-f", "cmake", "configure", "fdisk", "gdisk", "install", "make", "mv", "ninja", "rm", "rmdir"}` 77 fmt.Println(inputString) 78 sorted, err := sortStrings(inputString) 79 if err != nil { 80 panic(err) 81 } 82 fmt.Println(sorted) 83 // Output: 84 // addKeywords = []string{"z", "--force", "-f", "cmake", "configure", "fdisk", "gdisk", "install", "make", "mv", "ninja", "rm", "rmdir"} 85 // addKeywords = []string{"--force", "-f", "cmake", "configure", "fdisk", "gdisk", "install", "make", "mv", "ninja", "rm", "rmdir", "z"} 86} 87