Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gnomeSort(tab){
- var pos =0;
- while (pos<tab.length){
- if( pos==0 || tab[pos-1]<=tab[pos] )
- pos++;
- else{
- swap( tab, pos, pos-1 );
- pos--;
- }
- }
- function swap(t, i, j ){
- var temp = t[i];
- t[i] = t[j];
- t[j] = temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment