Here's St Basil's commentary from his epistle to
Optimus the Bishop:
By a sword is meant the word which tries and judges our thoughts, which pierces even to the dividing asunder of soul and spirit and of the joints and marrow, and is a discerner of our thoughts. Now every soul in the hour of the Passion was subjected, as it were, to a kind of searching. According to the word of the Lord it is said, All you shall be offended because of me (Matthew 26:3). Simeon therefore prophesies about Mary herself, that when standing by the cross, and beholding what is being done, and hearing the voices, after the witness of Gabriel, after her secret knowledge of the divine conception, after the great exhibition of miracles, she shall feel about her soul a mighty tempest. The Lord was bound to taste of death for every man — to become a propitiation for the world and to justify all men by His own blood. Even you yourself, who hast been taught from on high the things concerning the Lord, shall be reached by some doubt. This is the sword. That the thoughts of many hearts may be revealed. He indicates that after the offense at the Cross of Christ a certain swift healing shall come from the Lord to the disciples and to Mary herself, confirming their heart in faith in Him. In the same way we saw Peter, after he had been offended, holding more firmly to his faith in Christ. What was human in him was proved unsound, that the power of the Lord might be shown.