From 11a5faca1dc35bc6c7af3d4c22f973c19b2fc34d Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Fri, 11 Oct 2019 08:59:40 +0800 Subject: [PATCH] =?UTF-8?q?Utility=E5=A2=9E=E5=8A=A0reverseSort=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/util/Utility.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/org/redkale/util/Utility.java b/src/org/redkale/util/Utility.java index d9d41e02d..69e2aa340 100644 --- a/src/org/redkale/util/Utility.java +++ b/src/org/redkale/util/Utility.java @@ -610,6 +610,30 @@ public final class Utility { return news; } + /** + * 将int数组倒序 + * + * @param array 原数组 + * + * @return 新数组 + */ + public static int[] reverseSort(final int[] array) { + if (array == null || array.length == 0) return array; + return Arrays.stream(array).boxed().sorted(Collections.reverseOrder()).mapToInt(x -> x).toArray(); + } + + /** + * 将long数组倒序 + * + * @param array 原数组 + * + * @return 新数组 + */ + public static long[] reverseSort(final long[] array) { + if (array == null || array.length == 0) return array; + return Arrays.stream(array).boxed().sorted(Collections.reverseOrder()).mapToLong(x -> x).toArray(); + } + /** * 将元素从数组中删除 *