#NEWLINE# def counting_sort( array , maxval ) : #NEWLINE# #INDENT# "\n    Sorts the list 'array' using counting sort\n\n    >>> from pydsa import counting_sort\n    >>> a = [5, 6, 1, 9, 3]\n    >>> counting_sort(a, 9)\n    [1, 3, 5, 6, 9]\n\n    " #NEWLINE# count = ( [ 0 ] * ( maxval + 1 ) ) #NEWLINE# for a in array : #NEWLINE# #INDENT# count [ a ] += 1 #NEWLINE# #UNINDENT# i = 0 #NEWLINE# for a in range ( ( maxval + 1 ) ) : #NEWLINE# #INDENT# for c in range ( count [ c ] ) : #NEWLINE# #INDENT# array [ i ] = a #NEWLINE# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# return array