Swap two elements in a list.
list (list of objects): List of items in which two will swap positions
Click on an empty cell in each list to add a list item. A cell can contain only one list item.
first position (number): First of the two list items that will exchange positions; note that the first item in the list holds a position index value of 0
second position (number): Second of the two list items that will exchange positions
- new list: Resulting list with swapped elements
This is a list of six names:
Bethany has a position index value of 2, and Alan has a position index value of 0. To swap their positions, enter the elements from this list in the list field, enter 0 in the first position field, and 2 in the second position field. This is the resulting list: