Fixed sortBook method