(arr []T)
| 14 | import "github.com/TheAlgorithms/Go/constraints" |
| 15 | |
| 16 | func Simple[T constraints.Ordered](arr []T) []T { |
| 17 | for i := 0; i < len(arr); i++ { |
| 18 | for j := 0; j < len(arr); j++ { |
| 19 | if arr[i] < arr[j] { |
| 20 | // swap arr[i] and arr[j] |
| 21 | arr[i], arr[j] = arr[j], arr[i] |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | return arr |
| 26 | } |
| 27 | |
| 28 | // ImprovedSimple is a improve SimpleSort by skipping an unnecessary comparison of the first and last. |
| 29 | // This improved version is more similar to implementation of insertion sort |
nothing calls this directly
no outgoing calls
no test coverage detected