Sorting records in a mysql table

The site has a slider show. In the admin panel there is a setting item. It displays all the pictures in the order they were added to the database. Screwed the buttons up and down to change the order of the sliders.
Let’s say there are sliders in the order 1,2,3,4. I set a new order – 3,1,4,2, press the Update button, and now I need to fix the whole thing in the database.
The table in the database has the following structure:

id,parent,key,name,type. 

In this case, only idand nameare involved.

"1,0,'',img1.jpg,section_slider" 

etc.
It will not work to immediately assign new IDs to everyone at once, it is necessary somehow through the buffer. It is possible to create a buffer entry, using typeto indicate what it is for. Please tell me how to do it faster. The number of sliders can theoretically be any, but in practice there were no more than 10. The option “delete records, create new ones” is not suitable. It is necessary to update the existing id.


Answer 1, authority 100%

Everything is somewhat simpler than it seemed, and DebilSort did not help.
How I solved the problem:
Through jQuery, the sortable element exposed the new order of the sliders. And by pressing the Save order button, I get a list of id in the order I need. I write it to $data. I also make a selection from the database and get the old order of the sliders, write it to the sliders (it looks like an array (id, parent, key, name, type)). I have an mvc system, so I pass this whole thing to a function that works with the model. Function code:

public function updateSliderOrder($data,$sliders)
{
    if (count($data)==count($sliders)){
        foreach ($sliders as $key=>$slider){
            $this->_updateData(array('id'=>'0'),array('id'=>$slider['id']),$this->_settings);
            $this->_updateData(array('id'=>$slider['id']),array('id'=>$data[$key]),$this->_settings);
            $this->_updateData(array('id'=>$data[$key]),array('id'=>'0'),$this->_settings);
        }
    }
}

PHP Doc for _upadateData:
/
* update data in table


* @param array $data array with pairs key=val of field and his value.
* @param mixed $where sql where clause. can be array with key=val or string with conditions without ‘WHERE’
* @param strring $table [optional] table name on process with.
* @return boolean on success return true otherwise false
/


Answer 2

Do not store “a lot of junk” in one table and create a normal table where the information you need will be stored. and name and position etc.