Hi LuigiDiPalo,
Have you considered merge sort? There are c code for merge sort readily available on web. Using "merge sort c code" can find them. For your case, you may need to modify the c code, which you take from the web, to accomondate the 2nd array (if you do not change the code and let the code run twice, each for one array; that will also be good -- slower and take less memory).
The reason I mention merge sort: the selection sort algorithm you are using has a speed of O(n^2) while merge sort O(n*log(n)). Even for the worst case, merge sort still has speed of O(n*log(n)).
Best Regards,
Guolin