code: function (collection, elements, oldIndex, newIndex) {
  
              var settings = collection.data('collection-settings');
  
              if (!settings.position_field_selector && !settings.preserve_names) {
                  changeElementIndex(collection, elements, settings, oldIndex, oldIndex, '__swap__');
                  changeElementIndex(collection, elements, settings, newIndex, newIndex, oldIndex);
                  changeElementIndex(collection, elements, settings, oldIndex, '__swap__', newIndex);
              }
  
              elements.eq(oldIndex).insertBefore(elements.eq(newIndex));
              if (newIndex > oldIndex) {
                  elements.eq(newIndex).insertBefore(elements.eq(oldIndex));
              } else {
                  elements.eq(newIndex).insertAfter(elements.eq(oldIndex));
              }
  
              return collection.find(settings.elements_selector);
          }
docs: this method does the whole magic: in a collection, if we want to move elements and keep element positions in the backend, we should either move element names or element contents, but not both! thus, if you just move elements in the dom, you keep field names and data attached and nothing will change in the backend.