// RadixSort implement a decimal based radix sort
RadixSort implement a decimal based radix sort
// RadixSort implement a decimal based radix sort
func RadixSort(in []int) {
	if len(in) <= 1 {
		return
	}
	k := findMaxElement(in)
	s := 10 
	var d int
	newK := k
	for newK > 0 {
		d++
		newK /= s
	}
	internalCountingSort := func(in []int, p int) { 
		counting := make([]int, s, s) 
		out := make([]int, len(in), len(in))
		for _, v := range in {
			pv := (v / p) % s
			counting[pv]++
		}
		for i := 1; i < s; i++ {
			counting[i] += counting[i-1]
		}
		for j := len(in) - 1; j >= 0; j-- {
			v := in[j]
			pv := (v / p) % s
			out[counting[pv]-1] = v
			counting[pv]--
		}
		in = in[:0]
		in = append(in, out...)
	}
	for i := 0; i < d; i++ {
		p := (int)(math.Pow10(i))
		internalCountingSort(in, p)
	}
}
func RadixSort ( in [ ] int ) { if len ( in ) <= 1 { return } k := findMaxElement ( in ) s := 10 var d int newK := k for newK > 0 { d ++ newK /= s } internalCountingSort := func ( in [ ] int , p int ) { counting := make ( [ ] int , s , s ) out := make ( [ ] int , len ( in ) , len ( in ) ) for _ , v := range in { pv := ( v / p ) % s counting [ pv ] ++ } for i := 1 ; i < s ; i ++ { counting [ i ] += counting [ i - 1 ] } for j := len ( in ) - 1 ; j >= 0 ; j -- { v := in [ j ] pv := ( v / p ) % s out [ counting [ pv ] - 1 ] = v counting [ pv ] -- } in = in [ : 0 ] in = append ( in , out ... ) } for i := 0 ; i < d ; i ++ { p := ( int ) ( math . Pow10 ( i ) ) internalCountingSort ( in , p ) } }
RadixSort implement a decimal based radix sort
RadixSort implement a decimal based radix sort
// find max value from in // decimal // MUST be stable sort // all elements will be initialized by 0 // copy out back to in