We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi. The sort method takes 4 parameters. The first parameter is the array to sort. The next 2 parameters are the range to sort from [0,n] exclusive (includes 0 but not n). The last argument is the customComparator that I wrote to teach it how to sort.
The customComparator I wrote is a Comparator, and it must override the compare function. Reading the documentation for compare will answer most of your questions If the compare function returns a negative value, then s1 comes before s2. If it returns a positive value, then s2 comes before s1. Based on that information, Arrays.sort can sort arrays.
Java BigDecimal
You are viewing a single comment's thread. Return to all comments →
Hi. The sort method takes 4 parameters. The first parameter is the array to sort. The next 2 parameters are the range to sort from [0,n] exclusive (includes 0 but not n). The last argument is the customComparator that I wrote to teach it how to sort.
The customComparator I wrote is a Comparator, and it must override the compare function. Reading the documentation for compare will answer most of your questions If the compare function returns a negative value, then s1 comes before s2. If it returns a positive value, then s2 comes before s1. Based on that information, Arrays.sort can sort arrays.
HackerRank solutions.