This example shows how to use bubble sort. You can copy and past the below code over these or write your own.
function sort(items) {
// write your logic to sort and do not forget to return the list
// You cannot use array.sort() method.
var swapped;
do {
swapped = false;
for (var i=0; i < items.length-1; i++) {
if (items[i] > items[i+1]) {
var temp = items[i];
items[i] = items[i+1];
items[i+1] = temp;
swapped = true;
}
}
} while (swapped);
return items;
}