This construction can be used, among other times, when two nouns are often linked by a preposition

Answer to/of/for a question -----> ... question, the answer to/of/for which....

a/the key to a door -----> ... door, a/the key to which....


"He noticed the door, the key to which had been lost, was still locked."

There's no other word order for this sentence. Anything else is either incorrect, stilted, or a different meaning.

As seems commonplace for this construction, you can replace "the key to which" with simply "whose key".


"He noticed the door was still locked, the key to which had been lost." - seems imbalanced for reasons unknown but is theoretically okay.