Like this:

The great companion Talha bin ‘Ubaidullah (radyAllahu ‘anhu) narrated that two men came to the Messenger of Allah (salla Allahu alayhi wa sallam) and became Muslim together. After accepting Islam one of them would strive harder than the other. The one who used to strive harder went out to fight in the way of Allah and was martyred. The other man who accepted Islam at the same time as the martyr lived a year longer, then he also passed away.

Later Talha reported that he saw in a dream that he was at the gate of Paradise and he saw those two men that had died. Then through the gates of Paradise someone came out and admitted the one who had died last into Jannah, then he came out again and admitted the one who died first as a martyr. Then he came back to Talha and said: ‘Go back, for your time has not yet come.’”

The next morning, Talha told the people of the dream and they were amazed. News of that reached the Messenger of Allah (salla Allahu alayhi wa sallam) and they told him the story.

The Prophet (salla Allahu alayhi wa sallam) said: “Why are you so amazed at that?”

They said: “O Messenger of Allah, the first one was the one who strove harder, and he died a martyr in the cause of Allah, but the other man (who didn’t strive as hard and was not a martyr) was admitted to Paradise before him?”

The Messenger of Allah (salla Allahu alayhi wa sallam) said: “Did he (the second man) not live for another year?” They said: “Yes.”

The Prophet (salla Allahu alayhi wa sallam) asked: “And did not Ramadan come and he fasted, and he offered such and such prayers during that year?” They said: “Yes.”

The Messenger of Allah (salla Allahu alayhi wa sallam) said: “The difference between them is greater than the difference between the heaven and the earth.”– Collected by Ibn Majah