冒泡排序

package com.prh.sort;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        int[] a = {6,5,4,68,1,9,123,44,7};
        //创建新数组来接收排序好的数组
        int[] sort = Sort(a);
        System.out.println(Arrays.toString(sort));

    }
    //冒泡排序
    public static int[] Sort(int[] array){
        //用于判断需要循环次数
        for (int i = 0; i < array.length-1; i++) {
            //用于排序
           for (int j = 0;j < array.length-1; j++){
            //如果前面数组大于后面数组则互相替换
            if (array[j]>array[j+1]){
                   int mm = array[j+1];
                   array[j+1] = array[j];
                   array[j] = mm;
                   
               }
           }


        }
        return array;


    }

}