fix isSorted

This commit is contained in:
Kevin Xu 2019-04-24 13:59:18 +08:00
parent d90c27535c
commit 305dae1037

View File

@ -95,7 +95,7 @@ public class Bubble<T extends Comparable<T>> extends Sort<T> {
int N = nums.length; int N = nums.length;
boolean isSorted = false; boolean isSorted = false;
for (int i = N - 1; i > 0 && !isSorted; i--) { for (int i = N - 1; i > 0 && !isSorted; i--) {
hasSorted = true; isSorted = true;
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
if (less(nums[j + 1], nums[j])) { if (less(nums[j + 1], nums[j])) {
isSorted = false; isSorted = false;