<! doctype>/** * GetData method * Read the list of ID source, get the city name and the city corresponding air quality * return an array, format see example in function*/functionGetData () {varSource=document.getelementsbytagname ("Li");varNumber=document.getelementsbytagname ("B"); varData=NewArray (7); for(vari=0;i<data.length;i++) {data[i]=NewArray (2);}; //Define a two-dimensional array in JavaScript varI=0; while(Source[i]) {data[i][0]=source[i].innertext.replace (Number[i].innertext, ""); //The addition and subtraction of strings to the Replace function data[i][1]=number[i].innertext;i++;}; returndata;}functionSortaqidata (data) {varJ=0, I; while(j<6) //Sort the two-dimensional array by one digit size {i=j+1; while(i<7){ if(data[j][1]<data[i][1]) {varTEMP=DATA[J];d ata[j]=data[i];d ata[i]=temp;} i++;}; J++;};returndata;}functionrender (data) {varI=0; while(i<data.length) { varWrote=document.createelement ("Li"); i++; Wrote.innertext= "+i+" name "+data[i-1][0]+" "+data[i-1][1]; varResort=document.getelementbyid ("Resort"); Resort.appendchild (wrote); //Note that you should create child elements and add content before binding the child elements of the Parent element}}functionBtnhandle () {varAqidata =GetData (); Aqidata=Sortaqidata (Aqidata); Render (Aqidata);}functioninit () {varButton=document.getelementbyid ("Sort-btn"); Button.addeventlistener ("Click", Btnhandle); //under this, bind a click event to SORT-BTN and trigger the Btnhandle function when clicked.}init ();</script></body>Code exercises (definition of two-dimensional arrays, string addition and subtraction, creation and binding of child elements, sorting algorithm)