dropdownsarenotsorted

drop-downs are not getting sorted based on each other

by Junior Software Engineer

HTML

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
		sortDatePlugin();
		$.fn.dataTable.moment('M/D/YYYY');


    $('#example').DataTable( {
  "dom" : '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>',
        initComplete: function () {
            this.api().columns().every( function () {
                var column = this;
                if (column.index() !== 3 && column.index() !== 4 ) {
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                       countstageplan();
                    } );
                 column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
  }
                         var table = $('#example').DataTable();
                        buildSelect( table );
                        table.on( 'draw', function () {
                          buildSelect( table );
                        } );
            } );
        }
    } );
} );

function buildSelect( table ) {
  table.columns().every( function () {
    var column = table.column( this, {search: 'applied'} );
    var select =...