By array list I presume you mean java.lang.ArrayList? It usually maintains its elements in the order they were added, assuming you add them in order.will add however many Foos and maintain them in order whereaswill get them all in reverse order. (As well as slower performance.)
To try to finish your query: sorting with Comparable sorts by the "natural order" and sorting with a Comparator sorts by whatever the Comparator thinks it is supposed to sort by. After sorting you will have lost the insertion order.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: why arrayLIst does not sort the elements i add