46 lines
728 B
Go
46 lines
728 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
var numArray = []float64{}
|
|
var numToAdd int
|
|
var err error
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
fmt.Println("[-] Not enough arguments")
|
|
os.Exit(1)
|
|
}
|
|
for i := 1; i < (len(os.Args)); i++ {
|
|
numToAdd, err = strconv.Atoi(os.Args[i])
|
|
numArray = append(numArray, float64(numToAdd))
|
|
}
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println("RESULTS:")
|
|
fmt.Println(numArray)
|
|
|
|
fmt.Printf("\nSORTED RESULTS:\n")
|
|
sortedArray := sorter(numArray)
|
|
fmt.Printf("%v\n", sortedArray)
|
|
}
|
|
|
|
func sorter(arr []float64) (orderedArr []float64) {
|
|
if len(arr) == 0 {
|
|
return nil
|
|
}
|
|
for i := 0; i < len(arr); i++ {
|
|
for _, v := range arr {
|
|
orderedArr = append(orderedArr, v)
|
|
}
|
|
}
|
|
return
|
|
}
|