Question d’entretien chez Goldman Sachs

How to sort the elements in arraylist and also how to reverse them?