Right before he cuts off Nagini’s head, how did Neville get Gryffindor’s sword, if Griphook had it last?
As Harry is laying on the ground with everybody thinking he is dead, Neville steps up to challenge Voldemort. Voldemort causes the Hogwarts sorting hat to fly out of the castle and into his hands. Explaining that it won’t be needed anymore, he forces the hat onto Neville’s head and causes it burst into flames. And then all hell breaks loose as the good guys attack.
With this, Neville springs into action:
In one swift, fluid motion, Neville broke free of the Body-Bind Curse upon him; the flaming hat fell off him and he drew from its depths something silver, with a glittering, rubied handle
DH pg 733/587
So, finally showing the bravery of a true Gryffindor, Neville pulled the sword out of the hat, exactly as Harry did in the Chamber of Secrets.
But how did the sorting hat get the sword when Griphook had it last? The book does not say, but now that we’ve seen the hat do it twice, (Harry in the Chamber of Secrets and now Neville in Deathly Hallows), we have to assume that the hat has the magical ability to conjure up Gryffindor’s sword from wherever it is, whenever a true Gryffindor shows the courage required and has a need for it.