I'm looking for an easy way to iterate over a set by a user selected index.
(example)
How can I dynamically change the iterator used in this loop to let the user decide the sort criteria?
The loop is resolved at compile time. You will have to use a higher level approach to dynamically choose between the two hard-code loops.
Maybe a simple switch is enough in this case.