From ff846dd0b49447680f1031a9e04796abaecf1de1 Mon Sep 17 00:00:00 2001 From: JohnSimith <873764691@qq.com> Date: Wed, 9 Aug 2023 11:27:51 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E4=B8=8B=E6=A0=87=E8=B6=8A=E7=95=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/hutool/core/array/ArrayWrapper.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayWrapper.java b/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayWrapper.java index 1223329d1..91de0216d 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayWrapper.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayWrapper.java @@ -550,12 +550,14 @@ public class ArrayWrapper implements Wrapper, Iterable { } int compare; - for (int i = 0; i < this.length; i++) { + for (int i = 0; i < this.length - 1; i++) { compare = comparator.compare(get(i), get(i + 1)); - if ((isDESC && compare < 0) || - (!isDESC && compare > 0)) { - // 反序,前一个小于后一个则返回错 - // 正序,前一个大于后一个则返回错 + // 反序,前一个小于后一个则返回错 + if (isDESC && compare < 0) { + return false; + } + // 正序,前一个大于后一个则返回错 + if(!isDESC && compare > 0){ return false; } }