layout-parser icon indicating copy to clipboard operation
layout-parser copied to clipboard

TypeError: 'inplace' is an invalid keyword argument for sort()

Open talhaanwarch opened this issue 2 years ago • 1 comments

The documentation at this link is throwing an error .

TypeError: 'inplace' is an invalid keyword argument for sort()

The line which is throwing this error is

right_blocks = [b for b in text_blocks if b not in left_blocks]
right_blocks.sort(key = lambda b:b.coordinates[1], inplace=True)

Basically the sort function which take inplace parameter is layoutparser element as in case of left_block. right_block is a list and list sort dont have inplace parameter.

The right way to do is as follow

right_blocks=sorted(right_blocks,key = lambda b:b.coordinates[1])

talhaanwarch avatar Nov 15 '22 08:11 talhaanwarch

Thanks a ton @talhaanwarch, I was looking around the internet for this.

Mukilan-Krishnakumar avatar Sep 01 '23 06:09 Mukilan-Krishnakumar