Narrated 'Ali :
The Messenger of Allah (ﷺ) gave me two boys who were brothers, so I sold one of them, and the Messenger of Allah (ﷺ) said to me: 'O, 'Ali! What happened to your boy?' So I informed him, and he said: 'Return him, return him.'
[Abu 'Eisa said:] This Hadith is Hasan Gharib. Some of the people of knowledge among the Companions of the Prophet (ﷺ) and others, disliked separating between the captives when selling them.
Some of the people of knowledge permitted separating the children that were born in the land of Islam, but the first view is more correct. It has been related that Ibrahim An-Nakha'i seperated a mother and her child in a sale, so he was asked about that. He said: I sought her permission for that and she approved