JSFiddle - React, Tailwind, and code Playground

by telizpablo

JavaScript

package aula04;

import java.lang.reflect.Array;
import java.util.Random;

public class BubleSort {
	
	public static int[] constroiVetor(int n) {
		int[] v = new int[n];
		Random r = new Random();
		for (int i = 0; i < v.length; i++) {
			v[i] = r.nextInt();
		}
		return v;
	}
	
	public static int[] OrdenaBuble(int[] n) {
		
		for (int i = 0; i < n.length; i++) {
			for (int j = 0; j < n.length; j++) {
				int aux = 0;
				if(isset($arr[$j+1])){
					if($arr[$j] > $arr[$j+1]){
						$aux = $arr[$j+1];
						$arr[$j+1] = $arr[$j];
						$arr[$j] = $aux;
					}
				}
				
			}
			
		}

		return v;
	}
	
	public static void main(String[] args) {
		System.out.print(OrdenaBuble(constroiVetor(10)));
	}

}