Basically remember when Voldemort put the Sorting Hat on Neville after Neville confronts him when they all think that Harry is dead? Well, back in COS, Dumbledore کہا that only a true Gryffindor could pull the sword out of the hat, and quite simply Neville was a true Gryffindor which made all the goblin laws null and void and therefore caused the sword to be able to come out of the Sorting Hat. The wonderful Harry Potter parody script author, mollyringwraith, puts it into great terms in her Harry Potter and the Deathly Hallows Parody:
"VOLDEMORT: See, folks? Your little hero's just a limp piece of meat now. NEVILLE: Oi, you! Bite me! VOLDEMORT flicks the Sorting Hat onto NEVILLE's head with a few nasty curses attached. Big mistake. NEVILLE pulls the Sword of Gryffindor out of it. READERS: Hey, how did it end up in there? OTHER READERS: True Gryffindor, time of dire need, goblin rules of ownership null and void, blah blah blah. READERS: All right, all right. Onward."
PLEASE........TRY TO CHECK YOUR SPELLINGS BEFORE ADDING A QUESTION!! Actually, Griphook took the real sword, all right... آپ can trust a goblin to tell the difference, can't you? Like Hermione said, they could tell the 2 swords apart better than the trio could.
Griphook, that old rascal, double crossed the trio before they could double پار, صلیب him and took off with the real sword at Gringotts.
Neville, in the scene in question, had the Sorting Hat resting on his head. In the face of danger, it is to be expected that he appealed to the voice in it for help, the way Harry did in the Chamber. The sword of Gryffindor can be obtained only سے طرف کی true Gryffindors, and when Neville, a true Gryffindor called for its help, it sure as anything came to him through the hat, leaving behind a bewildered Griphook. SO I THINK آپ GOT YOUR ANSWER NOW!!!SPELL_O_CHARM!
Neville had just proven his courage and his worthiness of being in Griffindor سے طرف کی defying Voldemort. He had the Hat on his head. When that happens, I don't think it matters where the sword is currently, it's summoned into the Hat. I doubt it'd have been magically hidden within the Hat for the centuries before Harry first got it in book 2.