通过可拖动表永久更改记录的顺序

I have data table that populates data from the database, I'm using an Ajax Call to Populate the data on the table and I'm using jQuery RowSorter.js to make my table rows draggable. The my query in my data is sorted by sortorder column. Provided that it is draggable, how can I make the sort permanent in the table and be saved on the database. The sortorder should also be updated depending on what sort order the user choose in the draggable table rows. Here's my code:

Ajax:

$.ajax({
    url: "api/question/all", 
    type: 'GET',
    success: function(result){
    var myObj = $.parseJSON(result);
        $.each(myObj, function(key,value) {
            var t = $('#QuestionList').DataTable();

            t.row.add( [
                value.id,
                value.columnheader,
                value.costperlead,
                // value.isenabled,
                "<label class='toggle'><input type='checkbox' checked='' id='"+value.columnheader+"'><span class='handle'></span></label>",
                value.sortorder,
                "<a class='btn btn-small btn-info' href='<?php echo URL::to('question').'/';?>"+value.id+"/edit'><span class='glyphicon glyphicon glyphicon-edit' aria-hidden='true'></span></a>",
                "<form method='POST' action='<?php echo URL::to('question').'/';?>"+value.id+"' accept-charset='UTF-8' class='pull-left' >"+
                "<input name='_method' type='hidden' value='DELETE'>"+
                "<button type='submit' class='btn btn-warning'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button>"+"</form>",
            ] ).draw();

            if(value.isenabled == "Yes")
            {
                $("#"+value.columnheader).prop('checked', true);

            }
            else if(value.isenabled == "No")
            {
                $("#"+value.columnheader).prop('checked', false);

            }

        });
    }}).error(function(){
          progress.progressTimer('error', {
          errorText:'ERROR!',
          onFinish:function(){
            alert('There was an error processing your information!');
          }
        });
    }).done(function(){
        progress.progressTimer('complete');
        $( "#progressbar" ).fadeOut( "slow" );
    });

My Table HTML

<table id="QuestionList" class="table table-striped table-bordered" cellspacing="0" width="100%">
  <thead>
     <tr>
       <th colspan="5"> <center>Question Information<center></th>
       <th colspan="2"> <center>Actions<center></th>
     </tr>
     <tr>
        <th>ID</th>
        <th>Column Header</th>
        <th>Cost Per Lead</th>
        <th>Is Enabled?</th>
        <th>Sort Order</th>
        <th>Edit/View</th>
        <th>Delete</th>
      </tr>
   </thead>
      <tbody>

       </tbody>
       <tfoot>
            <tr>
                <td colspan="7">&nbsp;</td>
            </tr>
        </tfoot>
 </table> 

JS to Call rowsorter

$("#QuestionList").rowSorter({
    onDrop: function(tbody, row, index, oldIndex) {
        $(tbody).parent().find("tfoot > tr > td").html((oldIndex + 1) + ". row moved to " + (index + 1));
    }
});

My Query

public function apiGetQuestions()
{
    $questions = Question::orderBy('id', 'DESC')->get();
    return json_encode($questions);
}

I'm using Laravel 5, any ideas or guides will be appreciated. Thanks!

Update:

Using Jquery's rowsorter function I can keep track of the positions of the rows and its new position:

$(tbody).parent().find("tfoot > tr > td").html((oldIndex + 1) + ". row moved to " + (index + 1));

You don't want to store the entire table, but you can store the sorting events. Everytime a user clicks on a column, you add that to a sort sequence array and save the array serialized.

var sortSequence = [];
$('th').click(function() {
    // direction: 'asc' or 'desc'
    sortSequence[$(this).text()] = get_direction_from_jquery_sort_plugin_somehow();
    var data = {
        'table': ...,
        'sequence': sortSequence.serialize()
    };
    $.post('store-sequence', data);
});

I would then have some sanitization in place when storing the sorting to remove any duplication or ascending, descending, ascending sequences.

Then when retrieving the data, you add the sorting sequence as orderBy() calls.

$query = \DB::table("my_table")->where(...);

$sorts = $this->fetchSorting(\Auth::user(), "my_table");
foreach ($sorts as $column => $direction) {
    $query->orderBy($column, $direction);
}

This is all a lot of work however and I wonder if it is really worth it.