Ok lets consider this
Abraham was considered or reckoned righteous all the way back in Gen 15. When he believed God (see also romans 4)
This event happened Before Issac was even born, and before he had done any good works. which proved his faith
When abraham went to sacrifice his sin, He did so because he had TRUE faith in God, as apposed to the "CLAIMED" faith people that James was up against, who believed God but did not actually trust God. or in the gospel. they were just playing a game
The bible tells us how great Abrahams faith was, and why he was willing to sacrifice his son.
Heb 11: 17 By faith Abraham, when he was tested, offered up Isaac, and he who had received the promises offered up his only begotten son, 18 of whom it was said, “In Isaac your seed shall be called,” 19 concluding that God was able to raise him up, even from the dead, from which he also received him in a figurative sense.
You see Abrahams faith was not dead. It was living, Even though he doubted God many times, In his years of learning to trust God, his faith became so full that he trusted that since God promised a seed THROUGH this son, God would keep his promise by raising him from the dead.
But abraham was saved many many years earlier. When he trusted what God promises. If you have any doubt, see romans 4.