JS-- bubble sort
method one:
ARR = the let [7,12,3,8,1,9, -5,4,22 ] the let I, J, TEMP; the let K = arr.length for (I =. 1; I <K; I ++) { / / cyclic exchange round number for (J = 0; J <K - I; J ++) { // the number of each cycle of the IF (ARR [J]> ARR [J +. 1 ]) { TEMP = ARR [J] ARR [J] = ARR [J +. 1 ] ARR [J + 1'd] = TEMP } } } the console.log (ARR)
Method Two:
let arr=[7,12,3,8,1,9,-5,4,22] console.log(arr.sort(function(a,b) { return a-b }))