Sort by year-number
Sort by year-number
![pippuccio76](https://secure.gravatar.com/avatar/bac3a2e59be85aeac2071ddd3279a763/?default=https%3A%2F%2Fvanillicon.com%2Fbac3a2e59be85aeac2071ddd3279a763_200.png&rating=g&size=120)
HI i have a table with a culumn formed as year-number .
For example 2024-55
The problem is when i have 2024-6 datatable sort 2024-6 before 2024-55 in desc mode
How can i solve ?
HI i have a table with a culumn formed as year-number .
For example 2024-55
The problem is when i have 2024-6 datatable sort 2024-6 before 2024-55 in desc mode
How can i solve ?
Answers
The natural sorting plugin might do the job for you here.
Allan
Hi , i try to use natural sort :
[CODE]
$("#tabella-catalogo").DataTable({
columnDefs: [{
type: 'natural',
target: 2
}],
order: [
[2, 'desc'],
],
keys: true,
responsive: true,
select: true,
"language": {
"sEmptyTable": "Nessun dato presente nella tabella",
"sInfo": "Vista da START a END di TOTAL Record",
"sInfoEmpty": "Vista da 0 a 0 di 0 Record",
"sInfoFiltered": "(filtrati da MAX Record totali)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "Mostra MENU Record",
"sLoadingRecords": "Caricamento...",
"sProcessing": "Elaborazione...",
"sSearch": "Cerca:",
"sZeroRecords": "Nessun risultato.",
"oPaginate": {
"sFirst": "Inizio",
"sPrevious": "Precedente",
"sNext": "Successivo",
"sLast": "Fine"
},
"paginate": {
"previous": "<i class='fas fa-arrow-left'></i>",
"next": "<i class='fas fa-arrow-right'></i>"
}
},
"drawCallback": function() {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
}
});
[/CODE]
but doesn't work :
Did you load the plugin code?
I built a simple test case with a sample of your data and it seems to work:
https://live.datatables.net/wuhemamo/1/edit
If you still need help then please update my test case to show the issue or provide a link to your page so we can take a look.
Kevin