I need to build a table header from a list. I just need the first N items from the list. In this context, the order of this list REALLY matters. I need to be able to exact the N number of items into a new list and have the order preserved.
I can know/can count the value of N.
Here is an example of the list:
Alias Manager#Assurant#4;Alias Manager#1F-Secure#0;Alias Manager#NortonLifeLock#1;Password Manager#Assurant#3;Password Manager#1F-Secure#4;Password Manager#NortonLifeLock#3;Tracker Manager#Assurant#3;
You’ll note that the second item in each item in the list is an organization name.
$MyList3=$MyList3.unique; to retrieve the unique organization names. This does not work as this returns the list in alphabetical order:
1F-Secure;Assurant;NortonLifeLock. It is essential that I retain the order of the organization names, in this case:
Assurant;1F-Secure;NortonLifeLock. This list will be automatically generated. It could have as many as 15 repeating sets with 10~15 more times, and will change often, so finding a way to ensure the order is preserved is a must.
I tried using each with a counter, e.g. only cycle through .each N number of times and then stop. I can’t seem to get this idea to work, .each cycles through the entire list until it is completed with the list.
I was thinking of doing some kind of $MyList[1…N] loop operation in a function, but I can’t work through the logic, e.g. run function N times to build the new list.
Or, I’ve I had this list `Assurant;1F-Secure;NortonLifeLock;Assurant;1F-Secure;NortonLifeLock;Assurant;1F-Secure;NortonLifeLock;``` how do I lop off just the first N number of items, i.e.,
Does anyone have a clue how I could do this? I suspect I’m missing something very simple.