sort algo for books