jQuery(document).ready(function ($) {
    const $taxonomyList = $('#the-list'); // The list of terms

    $taxonomyList.sortable({
        update: function () {
            const order = $taxonomyList.sortable('toArray').map(id => id.replace('tag-', ''));

            // AJAX request to update order
            $.post(customSort.ajax_url, {
                action: 'save_taxonomy_order',
                order: order,
                nonce: customSort.nonce
            });
        }
    });
});