• This educational script will sort an array of tickers alphabetically and place these values in an table, together with the according current price value next to each ticker.
• the object object_1 consists off: · ticker -> "TICKER" · price -> current Daily close through request.security("TICKER") (non-repainting) • object_1 will be added to the aObjarray • "TICKER" (string ticker part of object) will be added to the sortarray
Alphabetically sorting is case sensitive, just like Java compareTo(String anotherString)! • The comparison is based on the Unicode value of each character in the string, the lowest "Dec" values are sorted first in line. • Comparing the "Dec" values at unicodelookup explains why default CAPITAL lettres will be sorted first, • Default you would get this (A= 65, B= 66, a= 97, b= 98)
• As a side note, should you write "AMZN" as "ÀMZN" this would be placed at the end, even after transforming to lower case the "Dec" values are higher (À= 192, à= 224).
• You can toggle "To Lower Case" to verify.
🔹 V. Values are placed in a table, using these sorted indices.
• With the usage of UDTs and objects, the current price has the same index in the aObj as their ticker, giving the advantage it is fairly easy to place every value correctly next to each other. • The same can be done by make 2 separate arrays, 1 for the current price, the other for "TICKER".