Cherrybrook Technology High School is not ranked in the top 40 schools. This year, it was ranked 81st and was ranked similarly in previous years. It is not impossible for comprehensive schools such as CTHS to rank relatively high, although it is unlikely to rank much higher (for example, in the top 40 schools) due to the fact that it is a comprehensive school and does not exert much influence/have much control over the quality of students that enrol at this school, as opposed to selective schools and private schools, which may require applicants to complete tests and/or provide evidence of high academic achievement for them to be considered. Even then, such students are not necessarily guaranteed an offer to attend such schools.
I personally perceive CTHS as being a better version of St Marys Senior High School, which is another school that tends to have a fair share of students that achieve favourable HSC results every year, despite the fact that it is also a comprehensive school. The school has improved its rank by 82 places between 2020 and this year. The reason that such schools can ensure that a considerable number of their students perform at a high standard in the HSC is likely linked to their enrolment process. For instance, SMSHS tends to select students who either have academic potential or those who possess non-academic qualities, but rejects students who cannot demonstrate either. While I do not know whether the same applies to CTHS, I would be inclined to believe that it does.
I hope this helps!