A small experiment to prove sortable problem can be solve easily with just a little bit of SQL
# Start PostgreSQL
docker run --rm --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=pass -d postgres
# Run the HTTP server
lein run
Generate 20 ordered items
curl -X PUT localhost:8080/items/reset/20
Get all the items
curl localhost:8080/items
Remove an item in the middle
curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"deleted": [10]}"'
10 # => 10 rows affected
Insert a new item at the end
curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"items" : [{"name": "New Item", "position": 20}]}"'
Move this item to second to last
curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"items" : [{"id": 21, "position": 19}]}"'
1 # => 1 row affected