Tsuna Sawada
Tsuna Sawada

Reputation: 349

How to bubble sort a arraylist in java?

How to bubble sort a arraylist in java?
i want to bubble sort an arraylist. or is there a better way to sort an arraylist or list.

Upvotes: 0

Views: 1781

Answers (2)

Timi
Timi

Reputation: 1

To sort an ArrayList I used the Collections.sort(), included the in the ArrayList class. eg.

 ArrayList<String> list = new ArrayList<String>();

To sort it I would say,

Collections.sort(list);

and this would sort the ArrayList

Upvotes: 0

Karl Knechtel
Karl Knechtel

Reputation: 61526

is there a better way to sort an arraylist or list.

Yes: use the sorting that is built into the standard library.

For example, http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html#sort%28java.util.List%29

Upvotes: 2

Related Questions