func radixSort(nums []uint16) { var ( lo [256]int hi [256]int ) for _, num := range nums { lo[num&0xff]++ hi[num>>8]++ } var ( loSum = 0 hiSum = 0 ) for i := 0; i < 256; i++ { loSum += lo[i] hiSum += hi[i] lo[i] = loSum hi[i] = hiSum } var ( have = len(nums) work = make([]uint16, have) ) for _, num := range nums { var ( i1 = num & 0xff i2 = lo[i1] ) work[i2] = num lo[i1] = i2 + 1 } for _, num := range work { var ( i1 = num >> 8 i2 = hi[i1] ) nums[i2] = num hi[i1] = i2 + 1 } }
To receive a hint, submit unfixed code.