package main import ( "fmt" "git.bulgariu.xyz/raul/min-max-array" "os" "strconv" ) var numArray = []float64{} var numToAdd int var err error func main() { if len(os.Args) < 2 { fmt.Println("Tool to automatically sort an array from the smallest number to the largest") fmt.Println("Usage: ./array-sorter 20 5 10") 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.Printf("%v\n", 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 } var numLocation int var numValue float64 sliced_arr := arr // TODO: get the actual sorting working for i := 0; i < len(arr); i++ { mini := minmax.Min(sliced_arr) orderedArr = append(orderedArr, mini) // TESTING (DELETING) ZONE for i, v := range sliced_arr { if v == minmax.Min(arr) { numLocation = i numValue = v } } sliced_arr = append(sliced_arr[:numLocation], sliced_arr[numLocation:]...) // TESTING ZONE } fmt.Printf("\nThe smallest value is %v and its position is %v\n\n", numValue, numLocation) //fmt.Printf("AAAA: %v", numLocation) //fmt.Printf("the identifier for the smallest number is %v", numLocation) // Why are you like this return orderedArr }