human
Sort elements by modulo with K | Utility function to prthe contents of an array.
Function to sort the array elements based on their modulo with K.
Create K empty vectors.
Update the vectors such that v [ i ] will contain all the elements that give remainder as i when divided by k.
Sorting all the vectors separately.
Replacing the elements in arr [ ] with the required modulo sorted elements.
Add all the elements of the current vector to the array.
Print the sorted array.
Driver code"
How can the above be solved in Python?

What is a code to sort elements by modulo with K and the other steps required?
assistant
#Here is code to sort elements by modulo with K and the other steps required.
 def printArr ( arr , n ) :
	for i in range ( n ) :
		print ( arr [ i ] , end = ' ▁ ' )
def sortWithRemainder ( arr , n , k ) :
	v = [ [ ] for i in range ( k ) ]
	for i in range ( n ) :
		v [ arr [ i ] % k ] . append ( arr [ i ] )
	for i in range ( k ) :
		v [ i ] . sort ( )
	j = 0
	for i in range ( k ) :
		for it in v [ i ] :
			arr [ j ] = it
			j += 1
	printArr ( arr , n )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 10 , 7 , 2 , 6 , 12 , 3 , 33 , 46 ]
	n = len ( arr )
	k = 4
	sortWithRemainder ( arr , n , k )