optimizing book sorting