#NEWLINE# def try_pack( tw , th , items ) : #NEWLINE# #INDENT# result = [ ] #NEWLINE# node = Node ( 0 , 0 , tw , th ) #NEWLINE# for ( index , ( w , h ) ) in items : #NEWLINE# #INDENT# position = node . insert ( w , h ) #NEWLINE# if ( position is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# result . append ( ( index , position ) ) #NEWLINE# #UNINDENT# result . sort ( ) #NEWLINE# result = [ x [ 1 ] for x in result ] #NEWLINE# return result