Manual sorting of database output
While technically this isn't reviewing your code, IMO this is the better solution: Do sort via MySQL

SELECT id, value, type 
FROM a_table 
WHERE id IN (15, 75, 45, 13);
ORDER BY FIELD(id, 15, 75, 45, 13)


PHP isn't the fastest language and should therefor not be used for sorting/ordering sets of data if other solutions are present. Looping in PHP is slow (but sometimes negligible, like the while(fetch)). MySQL, in this case, is a whole lot faster then PHP.

At the same time, this is more readable (IMO) and better to maintain.