【问题标题】:How to generate an array in Python which shows the positions of the highest to the lowest integers or floats in another array?如何在 Python 中生成一个数组,显示另一个数组中最高到最低整数或浮点数的位置?
【发布时间】:2022-07-21 18:54:20
【问题描述】:

我想生成一个数组,其中包含另一个数组中从最高整数/浮点数到最低的位置。 例如:

integers = [1,6,8,5] 我希望新生成的数组是: newArray = [2,1,3,0]

floatingPoints = [1.6,0.5,1.1] 会成为 newArray = [0,2,1]

【问题讨论】:

    标签: python arrays sorting integer


    【解决方案1】:

    我要做的只是使用降序对数组进行排序

    sorted = integers.sort()
    

    (see doc) 然后找到排序数组的所有元素的索引,看看this的答案。

    【讨论】:

      猜你喜欢
      • 2014-02-18
      • 1970-01-01
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 2011-06-27
      • 1970-01-01
      • 2015-04-08
      • 1970-01-01
      相关资源
      最近更新 更多