Ordering lessons in database