parent
26711cb7bc
commit
ca56a4faec
1 changed files with 28 additions and 0 deletions
@ -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…
Reference in new issue