common
排序算法

排序算法

插入排序

冒泡排序

public int[] sortArray(int[] nums) {
    int endIndex, currIndex, size = nums.length;
    if (size <= 1) {
        return nums;
    }
    for (endIndex = size - 1; endIndex > 0; --endIndex) {
        for (currIndex = 0; currIndex < endIndex; ++currIndex) {
            if (nums[currIndex] > nums[currIndex + 1]) {
                int swap = nums[currIndex];
                nums[currIndex] = nums[currIndex + 1];
                nums[currIndex + 1] = swap;
            }
        }
    }
    return nums;
}