mirror of
				https://github.com/golang/go.git
				synced 2025-10-31 08:40:55 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			62 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2009 The Go Authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| // $G $F.go && $L $F.$A && ./$A.out
 | |
| 
 | |
| package main
 | |
| 
 | |
| import Sort "sort"
 | |
| 
 | |
| func main() {
 | |
| 	{	data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586};
 | |
| 		a := Sort.IntArray{&data};
 | |
| 		
 | |
| 		Sort.Sort(&a);
 | |
| 
 | |
| 		/*
 | |
| 		for i := 0; i < len(data); i++ {
 | |
| 			print(data[i], " ");
 | |
| 		}
 | |
| 		print("\n");
 | |
| 		*/
 | |
| 		
 | |
| 		if !Sort.IsSorted(&a) {
 | |
| 			panic();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	{	data := []float{74.3, 59.0, 238.2, -784.0, 2.3, 9845.768, -959.7485, 905, 7.8, 7.8};
 | |
| 		a := Sort.FloatArray{&data};
 | |
| 		
 | |
| 		Sort.Sort(&a);
 | |
| 
 | |
| 		/*
 | |
| 		for i := 0; i < len(data); i++ {
 | |
| 			print(data[i], " ");
 | |
| 		}
 | |
| 		print("\n");
 | |
| 		*/
 | |
| 		
 | |
| 		if !Sort.IsSorted(&a) {
 | |
| 			panic();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	{	data := []string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "***"};
 | |
| 		a := Sort.StringArray{&data};
 | |
| 		
 | |
| 		Sort.Sort(&a);
 | |
| 
 | |
| 		/*
 | |
| 		for i := 0; i < len(data); i++ {
 | |
| 			print(data[i], " ");
 | |
| 		}
 | |
| 		print("\n");
 | |
| 		*/
 | |
| 		
 | |
| 		if !Sort.IsSorted(&a) {
 | |
| 			panic();
 | |
| 		}
 | |
| 	}
 | |
| }
 | 
