code: def move_window(self, window, new_index):
          
          assert isinstance(window, Window)
          assert isinstance(new_index, int)
  
          window.index = new_index
  
          # Sort windows by index.
          self.windows = sorted(self.windows, key=lambda w: w.index)
docs: Move window to a new index.