diff --git a/resources/views/components/tomselect.blade.php b/resources/views/components/tomselect.blade.php index 9e08eeb..ab114cf 100644 --- a/resources/views/components/tomselect.blade.php +++ b/resources/views/components/tomselect.blade.php @@ -19,12 +19,17 @@ dropdownParent: 'body', controlInput: '', sortField: [{ - field: '$text', + field: 'text', direction: 'asc' }], - render: { - option: function(item, escape) { - return '
' + escape(item.text) + '
'; + // Natural sort plugin or custom sorter: + // We use a custom sort function to handle the "1 - ..." format + // This ensures "1" < "2" < "10" + sortField: { + field: 'text', + direction: 'asc', + func: function(a, b) { + return a.text.localeCompare(b.text, undefined, {numeric: true, sensitivity: 'base'}); } } });