新增数组排序工具类

master
星期八 5 years ago
parent 26711cb7bc
commit ca56a4faec
  1. 28
      panda-code/src/main/java/org/panda/code/uitl/SortUtil.java

@ -0,0 +1,28 @@
package org.panda.code.uitl;
/**
* @Description 数组排序工具类
* @Author qi
**/
public class SortUtil {
/**
* 冒泡排序
* @param arr
* @return
*/
public static int[] bubblingSort(int[] arr){
int length = arr.length;
for (int i=0;i<length;i++){
for (int j=0;j<length-i-1;j++){
if (arr[j]>arr[j+1]) {
int temp = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}
}
Loading…
Cancel
Save