This quote is directly from Chamber of Secrets.
"If you want proof, Harry, that you belong in
Gryffindor, I suggest you look more closely at this."
Dumbledore reached across to Professor McGonagall's desk, picked
up the blood-stained silver sword, and handed it to Harry. Dully, Harry turned it over, the rubies blazing in the firelight. And then he saw the
name engraved just below the hilt.
Godric Gryffindor. "Only a true Gryffindor could have pulled that out of the hat, Harry," said Dumbledore simply.
~Chapter: Dobby's Reward
As per Harry Potter Wiki on the topic of sorting hat and sword of Gryffindor:
" The Sorting Hat originally belonged to Godric Gryffindor, one of the founders of Hogwarts. The Sorting Hat was sewn roughly one thousand years ago and was merely a normal hat belonging to Godric Gryffindor. When Gryffindor, along with Salazar Slytherin, Rowena Ravenclaw and Helga Hufflepuff, wondered how they would continue to sort the students when the four were dead, Gryffindor pulled his hat off of his head and, with the other founders, enchanted it with brains and some amount of personality. Godric Gryffindor's Sword, one of the founder's only other known relics, can be magically pulled out of the hat by any Gryffindor considered worthy, no matter how secure the sword's location."
So even if any student posses qualities "worthy of Gryffindor" (so to speak), they will not be able to draw the sword from the Hat as they do not belong to Gryffindor house.