基于另一个一维数组的值对python二维数组排序

2024-05-13 18:01:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个名为points的数组,它的形状是(408046,2)(408046对x,y),还有一个名为pointsValue的数组,它的形状是(408046,y)(408046对x,y的值)。我试图根据points的值对pointsValue进行排序。我试过使用下面的语法解释另一个StackOverflow问题(Sorting list based on values from another list?

pointSorted = [x for _,x in sorted(zip(points,pointsValue),reverse=True)]

但是,上面给出的错误是“ValueError:包含多个元素的数组的真值不明确。使用a.any()或a.all()“

谢谢


Tags: from排序on语法another数组stackoverflowpoints