Yusuf - 12:76

فَبَدَأَ بِأَوْعِيَتِهِمْ قَبْلَ وِعَاء أَخِيهِ ثُمَّ اسْتَخْرَجَهَا مِن وِعَاء أَخِيهِ كَذَلِكَ كِدْنَا لِيُوسُفَ مَا كَانَ لِيَأْخُذَ أَخَاهُ فِي دِينِ الْمَلِكِ إِلاَّ أَن يَشَاء اللّهُ نَرْفَعُ دَرَجَاتٍ مِّن نَّشَاء وَفَوْقَ كُلِّ ذِي عِلْمٍ عَلِيمٌ
[12:76]
So he began with their sacks before the sack of his brother, then he brought it out from his brother's sack. Thus did We plan for the sake of Yusuf; it was not (lawful) that he should take his brother under the king's law unless Allah pleased; We raise the degrees of whomsoever We please, and above every one possessed of knowledge is the All-knowing one.
So he began (the search) with their baggage, before (he came to) the baggage of his brother: at length he brought it out of his brother's baggage. Thus did We plan for Joseph. He could not take his brother by the law of the king except that Allah willed it (so). We raise to degrees (of wisdom) whom We please: but over all endued with knowledge is one, the All-Knowing.
Then he (Joseph) began the search with their bags before his brother's bag, then he produced it from his brother's bag. Thus did We contrive for Joseph. He could not have taken his brother according to the king's law unless Allah willed. We raise by grades (of mercy) whom We will, and over every lord of knowledge there is one more knowing.