Short answer
It depends on what is meant by “rank.” In the order of precedence, which governs who goes first at ceremonial occasions, Queen Camilla is generally placed ahead of Prince William. In the line of succession, which determines who inherits the throne, William is second and Camilla is not in the line at all.
Precedence versus succession
Precedence is about order of standing at events. Succession is about inheriting the crown. The two can point in different directions. The heir can be a high-ranking figure by succession but, among royals, the sovereign’s spouse is commonly placed directly after the sovereign.
How royal women are placed
By long convention, a royal wife takes her husband’s rank. A queen consort therefore sits near the top of the order, after the monarch, and she is ahead of the heir and the other royal princes. This is why Camilla, as the king’s wife, comes ahead of William in ordinary precedence.
Where William sits
William is the eldest son of the king and the Prince of Wales. After the King and Queen, he is usually next in the order. His place in the line of succession is second, behind only his own father. See our explanation of the British royal family order of precedence for the wider picture.
A caution
Formal precedence for the royal family is largely a matter of convention and royal practice, rather than a single statute. The exact order used at a particular event can vary, and the King can arrange it. For who inherits, see the current line of succession to the British throne.