Edit in JSFiddle

(function($) {
  $.fn.MyDatatable = function(options) {
    var rootElement = this;
    var defaults = {
      sortable: false
    };
    var settings = $.extend({}, defaults, options); //Gop tham so

    //Ham xu ly cho plugin
    var methods = {
      init: function() {},
      load: function() {},
      removeRow: function() {},
      searchValue: function() {},
      sortTable: function() {}
    };

    //Trien khai ham init
    methods.init = function() {
      methods.load();
      $('#search-table').keyup(function() {
        var value = $(this).val(); //Gia tri text input
        methods.searchValue(value);
      });
      $('#sort-table').click(function() {
        var type = 1;
        //Luu type vao thuoc tinh data-sort cua button
        if ($(this).attr('data-sort')) {
          type = parseInt($(this).attr('data-sort'));
        }
        methods.sortTable(type);
        $(this).attr('data-sort', -type); //Thay doi kieu sap xep nguoc lai
      });
    };

    //Trien khai ham load
    methods.load = function() {
      var container = rootElement.find('tbody.container');
      var defaultRow = rootElement.find('.clone-me'); //node DOM dung de sao chep
      //Them 100 dong moi vao table
      for (var i = 0; i < 100; i++) {
        var row = defaultRow.clone(); //Sao chep 1 node DOM moi
        row.removeClass('clone-me'); //Remove class css
        row.find('.id').html(i + 1); //Thay doi gia tri column Id
        row.find('.name').html('Ho va Ten ' + (i + 1)); //Thay doi gia tri column Name
        row.find('.score').html(Math.floor((Math.random() * 10) + 1)); //Thay doi gia tri column Score
        row.appendTo(container).show(); //Insert node DOM vao node cha tbody.container va hien thi

        row.click(function() {
          methods.removeRow(this);
        });
      }
    };

    methods.removeRow = function(row) {
      row = $(row);
      var id = row.find('.id').html();
      alert('Send xhr request to remove item having id = ' + id); //Thay cho goi ajax request
      row.remove();
    };

    methods.searchValue = function(value) {
      value = value.toLowerCase(); //So sanh lowercase
      var container = rootElement.find('tbody.container');
      container.find('tr').each(function(rowIndex, row) {
        //Duyet tung dong trong table
        row = $(row);
        var isFound = false;
        row.find('td').each(function(colIndex, column) {
          //Duyet tung cot trong dong
          var colVal = $(column).html().toLowerCase();
          if (colVal.indexOf(value) >= 0) {
            //Tim thay
            isFound = true;
            return; //break khi tim thay 1 column
          }
        });
        if (isFound) {
          row.show(); //Hien thi neu tim thay
        } else {
          row.hide(); //An neu khong tim thay
        }
      });
    };

    methods.sortTable = function(type) {
      //type = 1, sap xep tang dan
      //type = -1, sap xep giam dan
      var container = rootElement.find('tbody.container');
      container.find('tr').sort(function(rowA, rowB) {
        //tim kiem rowA Name, rowB Name de so sanh
        var nameA = $(rowA).find('.name').html();
        var nameB = $(rowB).find('.name').html();
        return nameB.localeCompare(nameA) * type;
      }).each(function(index, row) {
        $(row).appendTo(container); //Sap xep lai theo thu tu moi
      });
    };

    methods.init();
    //Ham xu ly cho plugin
    return rootElement; //Tra ve jQuery object
  };
})(jQuery);
<input type="text" id="search-table" />
<br/>
<button type="button" id="sort-table">Sort by name</button>
<table id="myDiv">
  <thead>
    <tr>
      <td>ID</td>
      <td>Name</td>
      <td>Score</td>
    </tr>
  </thead>
  <tbody>
    <tr class="clone-me" style="display: none;">
      <td class="id"></td>
      <td class="name"></td>
      <td class="score"></td>
    </tr>
  </tbody>
  <tbody class="container"></tbody>
</table>
<script>
  $('#myDiv').MyDatatable({
    sortable: true
  });

</script>

              

External resources loaded into this fiddle: