Q:

Sorting list of object by their date

I want to sort a list of Booking objects which was retrieved from a database. I want to sort this list and save it to orderedList. I then want to create another list which stores the last 10 bookings and next 10 bookings from todays date.
How can I do this? 
Date now = new Date();
    Session session = User.getSession();
    Transaction transaction = null;

    try {
        transaction = session.beginTransaction();

        String hql = "FROM Booking";
        Query query = session.createQuery(hql);
        List<Booking> bookingList = query.list();
        List<Booking> orderedList;

        for(int i =0; i<bookingList.size();i++){

        }

        transaction.commit();

A:

You can sort your result when retrieving from database itself
String hql = "FROM Booking ORDER BY column_name";

Sorting with Hibernate

