How can jQuery Sortable be used to collect IDs of sortable elements and send them to the server using Fetch API?

When using jQuery Sortable to allow users to reorder elements on a web page, you may want to collect the IDs of the sorted elements and send them to the server for further processing. This can be achieved by using the Sortable's `toArray` method to get the IDs of the sorted elements and then sending them to the server using the Fetch API.

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $sortedIds = json_decode(file_get_contents('php://input'), true);
    
    // Process the sorted IDs as needed
    // For example, update the database with the new order
    
    // Send a response back to the client
    echo json_encode(['success' => true]);
    exit;
}
?>
```

In your JavaScript code, you can use jQuery Sortable to get the sorted IDs and send them to the server using the Fetch API:

```javascript
$(function() {
    $('#sortable').sortable({
        update: function(event, ui) {
            var sortedIds = $('#sortable').sortable('toArray');
            
            fetch('your-server-url.php', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(sortedIds)
            })
            .then(response => response.json())
            .then(data => {
                console.log(data);
            })
            .catch(error => {
                console.error('Error:', error);
            });
        }
    });
});