
Hi,
How can I sort an arraylist without using Collection.sort() nad also I am not allowed to use any other data structure in the program? Is there any algorithm by using which I can do this?
Please help ....

Java Sort list without using Collections.sort() method
import java.util.*;
class SortList
{
public static void main(String[] args)
{
ArrayList<String> list=new ArrayList<String>();
list.add("D");
list.add("B");
list.add("A");
list.add("E");
list.add("C");
Object arr[] = list.toArray();
Arrays.sort(arr);
for(int i=0;i<arr.length;i++){
System.out.println(arr[i].toString());
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.