What kind of sorting method it is?

let arr=[57,2,3,12,43,23,23,43,56,98,03,77,23]
let insertion= a=>{
if(a.length<2){return a}
for(var i=0; i<a.length; i++){
//console.log(” value of i=”,i, “move to “, a[i])
let temp
if(a[i]<a[i+1]){


This content originally appeared on DEV Community and was authored by Riaj Ahmed

let arr=[57,2,3,12,43,23,23,43,56,98,03,77,23]
let insertion= a=>{
if(a.length<2){return a}
for(var i=0; i<a.length; i++){
//console.log(" value of i=",i, "move to ", a[i])
let temp
if(a[i]<a[i+1]){
//console.log( a[i], a[i+1])
temp=a[i]
a[i]=a[i+1]
a[i+1]=temp
i=i-2
}//else{console.log("nothing to do")}
}
return arr
}
console.log(insertion(arr))


This content originally appeared on DEV Community and was authored by Riaj Ahmed


Print Share Comment Cite Upload Translate Updates
APA

Riaj Ahmed | Sciencx (2021-09-26T10:06:46+00:00) What kind of sorting method it is?. Retrieved from https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/

MLA
" » What kind of sorting method it is?." Riaj Ahmed | Sciencx - Sunday September 26, 2021, https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/
HARVARD
Riaj Ahmed | Sciencx Sunday September 26, 2021 » What kind of sorting method it is?., viewed ,<https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/>
VANCOUVER
Riaj Ahmed | Sciencx - » What kind of sorting method it is?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/
CHICAGO
" » What kind of sorting method it is?." Riaj Ahmed | Sciencx - Accessed . https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/
IEEE
" » What kind of sorting method it is?." Riaj Ahmed | Sciencx [Online]. Available: https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/. [Accessed: ]
rf:citation
» What kind of sorting method it is? | Riaj Ahmed | Sciencx | https://www.scien.cx/2021/09/26/what-kind-of-sorting-method-it-is/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.