I have a collection of 10 items. They are ordered [0,1,2,3,4,5,6,7,8,9]. How can I arbitrarily move an item up and down in a collection. Note I am not looking for list based solutions. A collection is not a list…right? I am still a little grey on the difference between a collection and a list so I just wanted to mention that.
My 10 items are actually 10 cameras with various properties from a class. I want to be able to re-order these entries based upon the selected index in the list.
Say I have entry #2 selected and I click the UP operator.
The operator needs to take [0,1,2,3,4,5,6,7,8,9] and convert it to [0,2,1,3,4,5,6,7,8,9].
What is the best ‘pythonic’ way to accomplish such a task. I realize I can do brute force list scanning and reconstruction but I wondered if there was some hidden feature already built into collections?