human
Write me a code to sort the numbers according to their product of digits and the other steps required given the following:
Sort the numbers according to their product of digits | Function to return the product of the digits of n.
Function to sort the array according to the product of the digits of elements.
Vector to store the digit product with respective elements.
Inserting digit product with elements in the vector pair.
Sort the vector , this will sort the pair according to the product of the digits.
Print the sorted vector content.
Driver code"
Solution in Python:
assistant
#Here is code to sort the numbers according to their product of digits and the other steps required.
 def productOfDigit ( n ) :
	product = 1 ;
	while ( n > 0 ) :
		product *= ( n % 10 ) ;
		n = n // 10 ;
	return product ;
def sortArr ( arr , n ) :
	vp = [ ] ;
	for i in range ( n ) :
		vp . append ( ( productOfDigit ( arr [ i ] ) , arr [ i ] ) ) ;
	vp . sort ( ) ;
	for i in range ( len ( vp ) ) :
		print ( vp [ i ] [ 1 ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 12 , 10 , 102 , 31 , 15 ] ;
	n = len ( arr ) ;
	sortArr ( arr , n ) ;