I have a list of positions on the game board, i.e. each position is represented by a tuple: (row, column)
I want to sort the list from the most oriented position on the board to the outermost position.
So, I used positionsList.sort(key=howCentric), and howCentricreturns an integer that represents how centric the position is. the problem is that I would like to Centric function received 2 arguments: a tuple position and length of the card: def howCentric(position, boardSideLength).
Is it possible for a key function to receive more than one argument?
(I would not want to use a global variable because this is considered a bad habit, and obviously I would not want to create a position tuple that also contains the length of the side of the board, i.e. position = (row, column, boardSideLength))
source
share