mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 22:54:43 +01:00
33 lines
479 B
Go
33 lines
479 B
Go
package main
|
|
|
|
func main() {
|
|
|
|
}
|
|
|
|
func sortFor(n int, src []int) []int {
|
|
var find []int
|
|
var left []int
|
|
for _, x := range src {
|
|
if x == n {
|
|
find = append(find, x)
|
|
} else {
|
|
left = append(left, x)
|
|
}
|
|
}
|
|
return append(find, left...)
|
|
}
|
|
|
|
func sortFor2(n int, src []int) []int {
|
|
l := len(src)
|
|
for i := l - 1; i >= 0; i-- {
|
|
for j := l - 1; j >= 0; j-- {
|
|
if src[i] != n && src[j] == n {
|
|
tmp := src[i]
|
|
src[i] = src[j]
|
|
src[j] = tmp
|
|
}
|
|
}
|
|
}
|
|
return src
|
|
}
|