Utility增加reverseSort方法

This commit is contained in:
Redkale
2019-10-11 08:59:40 +08:00
parent c37b0e8cb5
commit 11a5faca1d

View File

@@ -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();
}
/**
* 将元素从数组中删除
*