@@ -0,0 +1,1499 @@
+%22%22%22%0AA simple (and probably hugely inefficient) radix sort implementation%0A%0AI couldn't think of a simple enough general interface that would allow to%0Aask to sort any kind of values, so I provide an implementation specifically%0Afor integers up to a given max value.%0A%0AAuthor:%0A  Christos Nitsas%0A  (nitsas)%0A  (nitsas.chris)%0A%0ALanguage:%0A  Python 3(.4)%0A%0ADate:%0A  May, 2016%0A%22%22%22%0A%0A%0Afrom math import log2%0Afrom collections import deque%0A%0A%0A__all__ = %5B'sort'%5D%0A%0A%0Adef sort_non_negative_integers(sequence, max_value):%0A    %22%22%22%0A    A simple (and probably hugely inefficient) radix sort implementation%0A    %0A    sequence -- a sequence of non-negative integers to sort%0A    max_value -- an upper bound for the values in the sequence%0A    %0A    Returns a list with the elements of the sequence sorted in non-decreasing%0A    order.%0A    %22%22%22%0A    %0A    zero_bit_queue = deque()%0A    one_bit_queue = deque()%0A    %0A    powers_of_two = (2 ** i for i in range(int(log2(max_value)) + 1))%0A    %0A    intermediate_list = list(sequence)%0A    for power_of_two in powers_of_two:%0A        for num in intermediate_list:%0A            if num & power_of_two %3E 0:%0A                one_bit_queue.append(num)%0A            else:%0A                zero_bit_queue.append(num)%0A        %0A        intermediate_list = list()%0A        for i in range(len(zero_bit_queue)):%0A            intermediate_list.append(zero_bit_queue.popleft())%0A        for i in range(len(one_bit_queue)):%0A            intermediate_list.append(one_bit_queue.popleft())%0A    %0A    return intermediate_list%0A

Add radix sort implementation for non-negative integers