Compare two string slices while ignoring the order of elements
(a, b []string)
| 139 | |
| 140 | // Compare two string slices while ignoring the order of elements |
| 141 | func IsEqualIgnoreOrder(a, b []string) bool { |
| 142 | if len(a) != len(b) { |
| 143 | return false |
| 144 | } |
| 145 | a_copy := make([]string, len(a)) |
| 146 | b_copy := make([]string, len(b)) |
| 147 | copy(a_copy, a) |
| 148 | copy(b_copy, b) |
| 149 | sort.Strings(a_copy) |
| 150 | sort.Strings(b_copy) |
| 151 | |
| 152 | return reflect.DeepEqual(a_copy, b_copy) |
| 153 | } |
| 154 | |
| 155 | // Iterate through slice and remove certain string, then return cleaned slice |
| 156 | func RemoveString(slice []string, s string) (result []string) { |
no outgoing calls