diff options
Diffstat (limited to 'sort/selection.go')
| -rw-r--r-- | sort/selection.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sort/selection.go b/sort/selection.go index e2a774c..2782460 100644 --- a/sort/selection.go +++ b/sort/selection.go @@ -7,18 +7,18 @@ import ( func Selection(a []ds.Comparer) []ds.Comparer { length := len(a) for i := 0; i < length; i++ { - max := i + min := i for j := i + 1; j < length; j++ { - if a[max].HigherThan(a[j]) { - max = j + if a[min].HigherThan(a[j]) { + min = j } } - if max == i { + if min == i { continue } tmp := a[i] - a[i] = a[max] - a[max] = tmp + a[i] = a[min] + a[min] = tmp } return a } |
