Originally Posted by

**afsina** No, binary search is used for finding an element in an already sorted array quickly. For example if you have a sorted integer array like this:

a[]={1,2,4,5,6,7,9,10,11,12,14,16,19,21,22}

binary search can find the position of "19" in only three steps. However, as you see the array is already sorted.

there are several sorting algorithms, if you want to learn ebout them, you can start with easy ones, such as selection sort, bubble sort or insertion sort. there are more complicated sort algorithms also such as quick sort, merge sort, radix sort or heap sort.

Java platform uses a modified merge sort, and qick sort for its sort facilities. There are Arrays.sort() for arrays, and Collections.sort() for Lists available. But i got that you are in the learning phase, not sur eif you want to use them.

Make a search in wikipedia about search algorithms or binary search, you can see several different implementations in various languages in the links area. Or Google it. For binary search or sort, you can also check how java is doing it by checking the source.