How to sort $N$ fractions from finite set We have $10^5$ fractions: $\frac{p}{2^q}$ such that $0 \leq p,q \leq 10$. 
  Find (fast) algorithm which sorts them.


I ask you to look at my proposition and tell me your ideas. $\frac{p}{q}$ is represented as the ordered pair $(p, q)$.

On input we have an array a.

My idea:

for i = 1 to n 
do t[i] = a[i].first * 2^(10)
countsort (t)
bring results from t to a (remember about / 2^10)


II Idea:  

for i = 1 to n do       
   t[i] = a[i].first * 2^(10)
{ now we have only integer numbers }
sort t by counting (as bucket use bits)
for i = 1 to n do
   a[i] = t/2^10


In this way we have O(n + log (10 * 1024)n) = O(14n).
What about this solution ?
You can sort all $11^2$ possible fractions, and create a table mapping $p/2^q$ to its position in this ordering, and another table going the other way. Then you can use counting sort to handle $N$ fractions in time $O(11^2 + N)$. (Here the underlying constant is universal, not depending on the size of the domain.)