How to sort Datatable by days in string value

  datatable, laravel

I am currently using Datatable in my laravel project for displaying my day configuration from my database. I would like to display my data in the following order, Monday -> Tuesday -> Wednesday etc.

Currently it is being ordered by alphabetical order from my database where the day column is store as string. Below are my javascript codes for my table.

 var ophrTables = $('#ophrs_table').DataTable({ 
            stateSave: true,
            columnDefs: [{
                    "searchable": false,
                    "orderable": false,
                    "targets": 0
            },{
                    "searchable": true,
                    "orderable": true,
                    "targets": 1
            },{
                    "searchable": false,
                    "orderable": false,
                    "targets": 2
            },{
                    "searchable": false,
                    "orderable": false,
                    "targets": 3
            }],
            order: [[ 1, 'asc' ]]
        });

Source: Laravel

Leave a Reply