<!DOCTYPE HTML>
<html lang="es">
<head>
<meta charset="utf-8">
<title>sortable</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
.elemento{
width:300px;
height: 200px;
border: 4px solid black;mm
background: lightblue;
margin: 20px;
float: left;
}
.lista-seleccionable li{
width: 80%;
padding: 20px;
border: 1px solid #ccc;
list-style: none;
cursor: pointer;
}
ul .ui-selecting {background: green;}
ul .ui-selected {background: blue;}
</style>
</head>
<body>
<h1>Ordenar </h1>
<ul class="lista-seleccionable">
<li data-orden="3">Tercero</li>
<li data-orden="5">Quinto</li>
<li data-orden="1">Primero</li>
<li data-orden="2">Segundo</li>
<li data-orden="4">Cuarto</li>
</ul>
<button type="button" onclick="verificar()">Verificar</button>
<script>
$(".lista-seleccionable").sortable();
function verificar() {
const elementos=[...document.querySelectorAll(".lista-seleccionable li")];
if (elementos.every((el, index) => parseInt(el.dataset.orden)==index+1)) {
alert("todos en orden");
} else {
alert("desordenados");
}
}
</script>
</body>
</html>