/// <summary> /// Sorts the input array based on each element's two's complement bitwise representation. /// </summary> public void Sort(Span <int> span) { for (int i = 0; i < 32; i += 4) { bool hasRemain = false; for (int j = 0; j < span.Length; j++) { uint number = Scalars.Int32ToUInt32Bits(span[j]); uint remain = number >> i; uint digit = remain & 0b1111; if (i == 28) { digit ^= 0b1000; } buckets[digit].Add(number); hasRemain |= remain != 0; } Copy(span, uintToIntConverter); Clear(); if (!hasRemain) { break; } } }