| 
									
										
										
										
											2018-12-05 15:02:03 +03:00
										 |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // --------------------------------------------------------- | 
					
						
							|  |  |  | // EXERCISE: Number Sorter | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  Your goal is to sort the given numbers from the command-line. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  1. Get the numbers from the command-line. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  2. Create an array and assign the given numbers to that array. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  3. Sort the given numbers and print them. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // RESTRICTION | 
					
						
							|  |  |  | //   + Maximum 5 numbers can be provided | 
					
						
							|  |  |  | //   + If one of the arguments are not a valid number, skip it | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // HINTS | 
					
						
							|  |  |  | //  + You can use the bubble-sort algorithm to sort the numbers. | 
					
						
							|  |  |  | //    Please watch this: https://youtu.be/nmhjrI-aW5o?t=7 | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2018-12-05 19:48:28 +03:00
										 |  |  | //  + When swapping the elements, do not check for the last element. | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2018-12-05 15:02:03 +03:00
										 |  |  | //    Or, you will receive this error: | 
					
						
							|  |  |  | //    "panic: runtime error: index out of range" | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // EXPECTED OUTPUT | 
					
						
							|  |  |  | //   go run main.go | 
					
						
							|  |  |  | //     Please give me up to 5 numbers. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   go run main.go 6 5 4 3 2 1 | 
					
						
							|  |  |  | //     Sorry. Go arrays are fixed. So, for now, I'm only supporting sorting 5 numbers... | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   go run main.go 5 4 3 2 1 | 
					
						
							|  |  |  | //     [1 2 3 4 5] | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   go run main.go 5 4 a c 1 | 
					
						
							|  |  |  | //     [0 0 1 4 5] | 
					
						
							|  |  |  | // --------------------------------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | } |