There's a difference between Java script and Java :P

However, the algorithm is the same. See Bubble sort for the pseudo-code.