Pine script 如何在pine脚本中按值浮点(value)和另一个字符串数组(key)对数组进行排序?

Pine script 如何在pine脚本中按值浮点(value)和另一个字符串数组(key)对数组进行排序?,pine-script,Pine Script,这是下面的一个示例脚本,因此我可以对包含任意顺序的值的一个数组进行排序,我还希望该顺序在另一个字符串数组(键)中也会受到影响。 如有需要,请要求澄清。 谢谢 字符串数组当前无法排序。我们向Pine团队提出了添加该功能的请求,但还没有ETA。是否有任何解决方法,我可以将两个数组作为键值对进行排序?我想按值数组对数组字符串进行排序。除了数组的自定义排序函数之外,目前还没有。我们建议Pine团队通过镜像主阵列的重新排序来提供对多个阵列的排序,但该功能尚未准备就绪。这将允许数组之间的虚拟链接,如表列。我

这是下面的一个示例脚本,因此我可以对包含任意顺序的值的一个数组进行排序,我还希望该顺序在另一个字符串数组(键)中也会受到影响。 如有需要,请要求澄清。 谢谢


字符串数组当前无法排序。我们向Pine团队提出了添加该功能的请求,但还没有ETA。

是否有任何解决方法,我可以将两个数组作为键值对进行排序?我想按值数组对数组字符串进行排序。除了数组的自定义排序函数之外,目前还没有。我们建议Pine团队通过镜像主阵列的重新排序来提供对多个阵列的排序,但该功能尚未准备就绪。这将允许数组之间的虚拟链接,如表列。我们在中还建议允许对字符串数组进行排序。当数组不需要排序时,您可以将索引保留到主数组中,以间接索引其他数组,但不幸的是,这不适用于您的问题。
//@version=4
study("Array sort feature", shorttitle="Ar_Srt", overlay=true)
var price = array.new_float(3, na)
var ticker = array.new_string(3, na)

btcusd = tickerid(prefix = "BITTREX", ticker = "BTCUSD", session = session.regular)
close_btcusd = security(btcusd, timeframe.period, close)
array.set(price, 0, close_btcusd)
array.set(ticker, 0, btcusd)

ethusd = tickerid(prefix = "BITTREX", ticker = "ETHUSD", session = session.regular)
close_ethusd = security(ethusd, timeframe.period, close)
array.set(price, 1, close_ethusd)
array.set(ticker, 1, ethusd)

dogeusd = tickerid(prefix = "BITTREX", ticker = "DOGEUSD", session = session.regular)
close_dogeusd = security(dogeusd, timeframe.period, close)
array.set(price, 2, close_dogeusd)
array.set(ticker, 2, dogeusd)


var label lbl = na
label.delete(lbl)
if barstate.islast
    lbl := label.new(time + 3600000 * timeframe.multiplier, high, tostring(ticker)+" \n"+tostring(price), xloc=xloc.bar_time, style = label.style_label_center, size = size.normal)
// sorted array label
array.sort(price, order.ascending)
var label lbl2 = na
label.delete(lbl2)
if barstate.islast
    lbl2 := label.new(time + 3600000 * timeframe.multiplier, high*0.99, tostring(ticker)+" \n"+tostring(price), xloc=xloc.bar_time, style = label.style_label_center, size = size.normal)