title: I need to reverse the selected slide order using Google Apps script
body: <p>I need to reverse the order of selected slides (if there is selection) otherwise reverse all the slides.</p>
  <p><a href="https://docs.google.com/presentation/d/1Bkhlu4DNT4vfiEo8iTb4KjkAQfXu8cihjn__s25o3AM/edit#slide=id.g9aebfd8249_0_0" rel="nofollow noreferrer">here is the code script editor file</a></p>
  <p>example slides 2 and slide 4 when selected then after the code execution</p>
  <p>Before: S1,S2,S3,S4<br />
  Expected result: S1,S4,S3,S2</p>
  <p>If no slides are selected</p>
  <p>Before: S1,S2,S3,S4<br />
  Expected result: S4,S3,S2,S1</p>
  <p>If slide 1, slide 2 and slide4 are selected</p>
  <p>Before: S1,S2,S3,S4<br />
  Expected result: S4,S2,S3,S1</p>
  <p>I have tried with</p>
  <pre><code>selectedArrayIndex = selectedArrayIndex.reverse();
  for (var k = selectedArrayIndex.length - 1; k &gt;= 0; k--) {
      allSlides[k].move(selectedArrayIndex[k] + 1);
  }
  </code></pre>