我有一个9×9正方形的网格。周围是一个更大的广场。方形角的坐标按以下方式存储在列表中:
# upper left corner = x1 y1
# lower left corner = x2 y2
# lower right corner = x3 x3
# upper right corner = x4 y4
我的清单:
^{pr2}$我知道我可以在角落里
my_list[0][0]
> [x1 y1]
例如和值:
my_list[0][0][0]
> x1
my_list[0][0][1]
> y1
但是,我不知道如何对列表进行排序,因为我有这样一个排序列表:
[[square1][square2][square3]...[square8][square9]
[square10][square11][square12]...[square17][square18]
.
.
.
[square72][square73][square74]...[square80][square81]]
square1应该是x1和y1最低的正方形。对吗,我只需要第一个,也许是左上角?因为网格正方形的长度和宽度是一样的。在
您可以将带有形状(9,9,2)的
my_list
展平到具有形状(1,81,2)的一维列表,对其进行排序,然后将其重塑为原始形状。在相关问题 更多 >
编程相关推荐