JSFiddle - React, Tailwind, and code Playground
JavaScript
function sort(ar) {
function log(c) {
document.documentElement.appendChild(document.createTextNode(c));
document.documentElement.appendChild(document.createElement('br'));
}
log(JSON.stringify(ar) + ":");
ar.sort(function (a, b) {
log("comparing " + a + " and " + b);
return a - b;
});
}
sort([1, 2, 3]);
sort([1, 3, 2]);
sort([2, 1, 3]);
sort([2, 3, 1]);
sort([3, 1, 2]);
sort([3, 2, 1]);