简体   繁体   中英

Custom sort in java and it's time complexity

int [][] countArr = new int[123][2];
Arrays.sort(countarr, (a,b) -> Integer.compare(b[0], a[0]));

what will be the time complexity for this custom sort in java?

Your example is not a custom sort. Your example might be "a custom comparison" + "the standard sort". You can multiply the complexities of the comparison and the sort. Java standard sort complexity is explained below:

Arrays.sort uses dual-pivot Quicksort on primitives. It offers O(n log(n)) performance and is typically faster than traditional (one-pivot) Quicksort implementations

Collections.sort, it uses modified mergesort and offers guaranteed O(n log(n)) performance.

source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM