How does sort function work?



How does sort function work?..

Answer / Varun Kumar Jha

The sort() method in Java compares each pair of adjacent elements and swaps them if they are in the wrong order (according to their natural order or a specified Comparator). The default natural ordering is implemented by comparing the objects' hash codes, but this can be customized with a Comparator.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is sorting in data structure?

1 Answers  


What happens when arraylist is full?

1 Answers  


What is the difference between array and stack in data structures?

1 Answers  


Briefly explain recursive algorithm?

1 Answers  


Can we add duplicate keys in a hashmap? What will happen if we attempt to add duplicate values?

1 Answers  


Is it possible to store null key and null values in a hashmap?

1 Answers  


What is the purpose of sorting algorithms?

1 Answers  


Does arraylist maintain order?

1 Answers  


How does quick sort work?

1 Answers  


What is binary tree?

13 Answers   BMC,


What is data structure explain different types of data structures with examples?

1 Answers  


In tree construction which is the suitable efficient data structure?

1 Answers  


Categories