Skip to main content
1 of 3
bill s
  • 70.1k
  • 4
  • 105
  • 200

Define the indices that you want to interchange in a list $ind$ and then you can index into the array $a$ directly.

a = {{1, 2, 3, 4, 5}, {2, 3, 4, 5, 6}, {3, 4, 5, 6, 7}, {4, 5, 6, 7, 8}, {5, 6, 7, 8, 9}}; ind = {1, 3, 4, 2, 5}; a[[ind, ind]] 
bill s
  • 70.1k
  • 4
  • 105
  • 200